【发布时间】:2018-09-11 13:29:11
【问题描述】:
当我烧写一个 pandas.dataframe 时,它可以正常输出列!当我运行“traffic.head()”时,它可以正常运行!但是,当我运行 "traffic.Stop_day" 时,它指示 AttributeError 如下所示:
import odo
traffic=bl.Data(df)
print(traffic.fields)
['代理', '子代理', '描述', '位置', '纬度', '经度', '事故', '腰带', '人身伤害', '财产损失', '致命', “商业执照”、“危险品”、“商用车”、“酒精”、“工作区”、“状态”、“车辆类型”、“年份”、“制造”、“型号”、“颜色”、“违规类型” ','收费','文章','促成事故','种族','性别','司机城市','司机状态','DL状态','逮捕类型','地理位置','Stop_month '、'Stop_day'、'Stop_year'、'Stop_hour'、'Stop_min'、'Stop_sec']
traffic.Stop_day
AttributeError Traceback(最近调用 最后的) e:\software\python36\lib\site-packages\IPython\core\formatters.py 在 调用(self, obj) 第700章 第701章 --> 702 打印机.pretty(obj) 703 打印机.flush() 704 返回流.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 返回_default_pprint(obj,self,cycle)
e:\software\python36\lib\site-packages\IPython\lib\pretty.py 在 _repr_pprint(obj, p, 循环) 693 """一个只重定向到正常 repr 函数的 pprint。""" 694 # 查找换行符并将其替换为 p.break_() --> 695 输出 = repr(obj) 696 for idx, output_line in enumerate(output.splitlines()): 第697章
e:\software\python36\lib\site-packages\blaze\interactive.py 在 _choose_repr(自我) 440 其他: 441 警告。警告(_warning_msg,弃用警告,堆栈级别=2) --> 442 返回 expr_repr(self) 443 第444章
e:\software\python36\lib\site-packages\blaze\interactive.py 在 expr_repr(expr, n) 第358章 第359章 --> 360 返回 repr_tables(expr, 10) 361 第362章
e:\software\python36\lib\site-packages\blaze\interactive.py 在 repr_tables(expr, n) 240 第241章 --> 242 结果=concrete_head(expr, n).rename(columns={None: ''}) 243 244 if isinstance(result, (DataFrame, Series)):
e:\software\python36\lib\site-packages\blaze\interactive.py 在 具体头(expr,n) 220 返回 odo(头,数据帧) 221 其他: --> 222 df = odo(head, DataFrame) 第223章 第224章
e:\software\python36\lib\site-packages\odo\odo.py in odo(source, 目标,**kwargs) 89 odo.append.append - 将事物添加到现有事物上 90""" ---> 91 返回到(目标,源,**kwargs)
e:\software\python36\lib\site-packages\multipledispatch\dispatcher.py 在 调用(self, *args, **kwargs) 第276章 277 尝试: --> 278 返回函数(*args,**kwargs) 279 280 除了 MDNotImplementedError:
e:\software\python36\lib\site-packages\blaze\interactive.py in into(a, b, **kwargs) 404 结果 = 计算(b,return_type='native',**kwargs) 405 kwargs ['dshape'] = b.dshape --> 406 返回到(a,结果,**kwargs) 407 第408章
e:\software\python36\lib\site-packages\multipledispatch\dispatcher.py 在 调用(self, *args, **kwargs) 第276章 277 尝试: --> 278 返回函数(*args,**kwargs) 279 280 除了 MDNotImplementedError:
e:\software\python36\lib\site-packages\odo\into.py in Wrapped(*args, **kwargs) 41 raise 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 为无: 52 dshape =发现(b) ---> 53 返回转换(a,b,dshape=dshape,**kwargs) 54 55
e:\software\python36\lib\site-packages\odo\core.py in call(self, *args, **kwargs) 42 43 def 调用(自我,*args,**kwargs): ---> 44 返回 _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 排除边缘=排除边缘, ---> 57 ooc_types=ooc_types) 58 尝试: 59 for (A, B, f) in pth:
e:\software\python36\lib\site-packages\odo\core.py in path(graph, 源、目标、excluded_edges、ooc_types) 92 pth = nx.shortest_path(g, source=source, target=target, weight='cost') 93 结果 = [(src, tgt, graph.edge[src][tgt]['func']) ---> 94 for src, tgt in zip(pth, pth[1:])] 95返回结果 96
e:\software\python36\lib\site-packages\odo\core.py in (.0) 92 pth = nx.shortest_path(g, source=source, target=target, weight='cost') 93 结果 = [(src, tgt, graph.edge[src][tgt]['func']) ---> 94 for src, tgt in zip(pth, pth[1:])] 95返回结果 96
AttributeError: 'DiGraph' 对象没有属性 'edge'
----------------------------------- ---------------------------- AttributeError Traceback(最近调用 最后的) e:\software\python36\lib\site-packages\IPython\core\formatters.py 在 调用(self, obj) 第343章 344 如果方法不是无: --> 345 返回方法() 第346章 347 其他:
e:\software\python36\lib\site-packages\blaze\interactive.py 在 _warning_repr_html(自我) 448 其他: 449 警告.warn(_warning_msg,弃用警告,stacklevel=2) --> 450 返回 to_html(self) 451 第452章
e:\software\python36\lib\site-packages\multipledispatch\dispatcher.py 在 调用(self, *args, **kwargs) 第276章 277 尝试: --> 278 返回函数(*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 在 具体头(expr,n) 220 返回 odo(头,数据帧) 221 其他: --> 222 df = odo(head, DataFrame) 第223章 第224章
e:\software\python36\lib\site-packages\odo\odo.py in odo(source, 目标,**kwargs) 89 odo.append.append - 将事物添加到现有事物上 90""" ---> 91 返回到(目标,源,**kwargs)
e:\software\python36\lib\site-packages\multipledispatch\dispatcher.py 在 调用(self, *args, **kwargs) 第276章 277 尝试: --> 278 返回函数(*args,**kwargs) 279 280 除了 MDNotImplementedError:
e:\software\python36\lib\site-packages\blaze\interactive.py in into(a, b, **kwargs) 404 结果 = 计算(b,return_type='native',**kwargs) 405 kwargs ['dshape'] = b.dshape --> 406 返回到(a,结果,**kwargs) 407 第408章
e:\software\python36\lib\site-packages\multipledispatch\dispatcher.py 在 调用(self, *args, **kwargs) 第276章 277 尝试: --> 278 返回函数(*args,**kwargs) 279 280 除了 MDNotImplementedError:
e:\software\python36\lib\site-packages\odo\into.py in Wrapped(*args, **kwargs) 41 raise 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 为无: 52 dshape =发现(b) ---> 53 返回转换(a,b,dshape=dshape,**kwargs) 54 55
e:\software\python36\lib\site-packages\odo\core.py in call(self, *args, **kwargs) 42 43 def 调用(自我,*args,**kwargs): ---> 44 返回 _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 排除边缘=排除边缘, ---> 57 ooc_types=ooc_types) 58 尝试: 59 for (A, B, f) in pth:
e:\software\python36\lib\site-packages\odo\core.py in path(graph, 源、目标、excluded_edges、ooc_types) 92 pth = nx.shortest_path(g, source=source, target=target, weight='cost') 93 结果 = [(src, tgt, graph.edge[src][tgt]['func']) ---> 94 for src, tgt in zip(pth, pth[1:])] 95返回结果 96
e:\software\python36\lib\site-packages\odo\core.py in (.0) 92 pth = nx.shortest_path(g, source=source, target=target, weight='cost') 93 结果 = [(src, tgt, graph.edge[src][tgt]['func']) ---> 94 for src, tgt in zip(pth, pth[1:])] 95返回结果 96
AttributeError: 'DiGraph' 对象没有属性 'edge'
那么,有什么问题呢?
【问题讨论】: