当我燃烧pandas.dataframe时,它可以正常输出列!当我运行“ traffic.head()”时,它可以正常运行!但是,当我运行“ traffic.Stop_day”时,它指示AttributeError如下:
import odo
traffic=bl.Data(df)
print(traffic.fields)
[“机构”,“子机构”,“描述”,“位置”,“纬度”,“经度”,“事故”,“皮带”,“人身伤害”,“财产损失”,“致命”, “商业许可证”,“ HAZMAT”,“商业车辆”,“酒精”,“工作区域”,“状态”,“车辆类型”,“年份”,“制造”,“型号”,“颜色”,“违规类型” ','收费','文章','促成事故','种族','性别','驾驶员城市','驾驶员状态','DL状态','逮捕类型','地理位置','停止月份','Stop_day','Stop_year','Stop_hour','Stop_min','Stop_sec']
traffic.Stop_day
AttributeError跟踪(最近的调用) 持续) e:\ software \ python36 \ lib \ site-packages \ IPython \ core \ formatters.py在 致电(自己,obj) 700 type_pprinters = self.type_printers, 701 deferred_pprinters = self.deferred_printers) -> 702 printer.pretty(obj) 703 printer.flush() 704返回stream.getvalue()
e:\ software \ python36 \ lib \ site-packages \ IPython \ lib \ pretty.py在 漂亮(自己,obj) 398如果cls不是对象 399和可调用(cls。 dict .get(' repr '))): -> 400 return _repr_pprint(obj,self,cycle) 401 402 return _default_pprint(obj,self,cycle)
e:\ software \ python36 \ lib \ site-packages \ IPython \ lib \ pretty.py在 _repr_pprint(obj,p,cycle) 693“”“仅重定向到常规repr功能的pprint。”“” 694#查找换行符并将其替换为p.break_() -> 695输出= repr(obj) 696用于idx,enumerate(output.splitlines())中的output_line: 697,如果是idx:
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py在 _choose_repr() 440: 441 warnings.warn(_warning_msg,DeprecationWarning,stacklevel = 2) -> 442 return expr_repr() 443 444
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py在 expr_repr(expr,n) 358 isscalar(expr.dshape.measure)或 359 isinstance(expr.dshape.measure,Map))): -> 360返回repr_tables(expr,10) 361 362#较小的数组
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py在 repr_tables(expr,n) 240 241 def repr_tables(expr,n = 10): -> 242结果= concrete_head(expr,n).rename(columns = {None:''}) 243 244 if isinstance(result,(DataFrame,Series)):
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py在 concrete_head(expr,n) 220 return odo(head,DataFrame) 221其他: -> 222 df = odo(head,DataFrame) 223 df.columns = [expr._name] 224 return df
e:odo中的e:\ software \ python36 \ lib \ site-packages \ odo \ odo.py(源代码, 目标,** kwargs) 89 odo.append.append-将事物添加到现有事物 90“”“ ---> 91返回(target,source,** kwargs)
e:\ software \ python36 \ lib \ site-packages \ multipledispatch \ dispatcher.py 在通话中(自己,* args,** kwargs) 276 self._cache [types] = func 277尝试: -> 278 return func(* args,** kwargs) 279 280,除了MDNotImplementedError:
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py in((a, b,** kwargs) 404结果= compute(b,return_type ='native',** kwargs) 405 kwargs ['dshape'] = b.dshape -> 406 return into(a,result,** kwargs) 407 408
e:\ software \ python36 \ lib \ site-packages \ multipledispatch \ dispatcher.py 在通话中(自己,* args,** kwargs) 276 self._cache [types] = func 277尝试: -> 278 return func(* args,** kwargs) 279 280,除了MDNotImplementedError:
e:\ software \ python36 \ lib \ site-packages \ odo \ into.py包装(* args, ** kwargs) 41引发TypeError('dshape参数不是DataShape的实例') 42 kwargs ['dshape'] = dshape -> 43返回f(* args,** kwargs) 44返回包装 45
e:\ software \ python36 \ lib \ site-packages \ odo \ into.py in into_type(a,b, dshape,** kwargs) 51如果dshape为None: 52 dshape =发现(b) ---> 53 return convert(a,b,dshape = dshape,** kwargs) 54 55
e:\ software \ python36 \ lib \ site-packages \ odo \ core.py in call ((自我, * args,** kwargs) 42 43 def call (自我,* args,** kwargs): ---> 44 return _transform(self.graph,* args,** kwargs) 45 46
e:\ software \ python36 \ lib \ site-packages \ odo \ core.py在 _transform(图形,目标,源,excluded_edges,ooc_types,** kwargs) 55 pth =路径(图形,类型(源),目标, 56 exclude_edges = excluded_edges, ---> 57个ooc_types = ooc_types) 58试试: pth中的(A,B,f)为59:
e:\ software \ python36 \ lib \ site-packages \ odo \ core.py在路径中(图, 源,目标,excluded_edges,ooc_types) 92 pth = nx.shortest_path(g,来源=来源,目标=目标,重量='成本') 93结果= [(src,tgt,graph.edge [src] [tgt] ['func']) -> zip(pth,pth [1:])中src和tgt的94 95返回结果 96
e :(。0)中的e:\ software \ python36 \ lib \ site-packages \ odo \ core.py 92 pth = nx.shortest_path(g,来源=来源,目标=目标,重量='成本') 93结果= [(src,tgt,graph.edge [src] [tgt] ['func']) -> zip(pth,pth [1:])中src和tgt的94 95返回结果 96
AttributeError:“ DiGraph”对象没有属性“ edge”
-------------------------------------------------- ---------------------------- AttributeError Traceback(最近一次调用 持续) e:\ software \ python36 \ lib \ site-packages \ IPython \ core \ formatters.py在 致电(自己,obj) 343方法= get_real_method(obj,self.print_method) 344如果方法不是None: -> 345 return method() 346返回无 347其他:
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py在 _warning_repr_html(个体) 第448章 449 warnings.warn(_warning_msg,DeprecationWarning,stacklevel = 2) -> 450返回to_html(个体) 451 452
e:\ software \ python36 \ lib \ site-packages \ multipledispatch \ dispatcher.py 在通话中(自己,* args,** kwargs) 276 self._cache [types] = func 277尝试: -> 278 return func(* args,** kwargs) 279 280,除了MDNotImplementedError:
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py在 to_html(expr) 387如果不是expr._resources()或ndim(expr)!= 1: 第388章 -> 389返回to_html(concrete_head(expr)) 390 391
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py在 concrete_head(expr,n) 220 return odo(head,DataFrame) 221其他: -> 222 df = odo(head,DataFrame) 223 df.columns = [expr._name] 224 return df
e:odo中的e:\ software \ python36 \ lib \ site-packages \ odo \ odo.py(源代码, 目标,** kwargs) 89 odo.append.append-将事物添加到现有事物 90“”“ ---> 91返回(target,source,** kwargs)
e:\ software \ python36 \ lib \ site-packages \ multipledispatch \ dispatcher.py 在通话中(自己,* args,** kwargs) 276 self._cache [types] = func 277尝试: -> 278 return func(* args,** kwargs) 279 280,除了MDNotImplementedError:
e:\ software \ python36 \ lib \ site-packages \ blaze \ interactive.py in((a, b,** kwargs) 404结果= compute(b,return_type ='native',** kwargs) 405 kwargs ['dshape'] = b.dshape -> 406 return into(a,result,** kwargs) 407 408
e:\ software \ python36 \ lib \ site-packages \ multipledispatch \ dispatcher.py 在通话中(自己,* args,** kwargs) 276 self._cache [types] = func 277尝试: -> 278 return func(* args,** kwargs) 279 280,除了MDNotImplementedError:
e:\ software \ python36 \ lib \ site-packages \ odo \ into.py包装(* args, ** kwargs) 41引发TypeError('dshape参数不是DataShape的实例') 42 kwargs ['dshape'] = dshape -> 43返回f(* args,** kwargs) 44返回包装 45
e:\ software \ python36 \ lib \ site-packages \ odo \ into.py in into_type(a,b, dshape,** kwargs) 51如果dshape为None: 52 dshape =发现(b) ---> 53 return convert(a,b,dshape = dshape,** kwargs) 54 55
e:\ software \ python36 \ lib \ site-packages \ odo \ core.py in call ((自我, * args,** kwargs) 42 43 def call (自我,* args,** kwargs): ---> 44 return _transform(self.graph,* args,** kwargs) 45 46
e:\ software \ python36 \ lib \ site-packages \ odo \ core.py在 _transform(图形,目标,源,excluded_edges,ooc_types,** kwargs) 55 pth =路径(图形,类型(源),目标, 56 exclude_edges = excluded_edges, ---> 57个ooc_types = ooc_types) 58试试: pth中的(A,B,f)为59:
e:\ software \ python36 \ lib \ site-packages \ odo \ core.py在路径中(图, 源,目标,excluded_edges,ooc_types) 92 pth = nx.shortest_path(g,来源=来源,目标=目标,重量='成本') 93结果= [(src,tgt,graph.edge [src] [tgt] ['func']) -> zip(pth,pth [1:])中src和tgt的94 95返回结果 96
e :(。0)中的e:\ software \ python36 \ lib \ site-packages \ odo \ core.py 92 pth = nx.shortest_path(g,来源=来源,目标=目标,重量='成本') 93结果= [(src,tgt,graph.edge [src] [tgt] ['func']) -> zip(pth,pth [1:])中src和tgt的94 95返回结果 96
AttributeError:“ DiGraph”对象没有属性“ edge”
那么,怎么了?
答案 0 :(得分:0)
只需使用命令“ traffic.data.Stop_year”!够了。