当我点亮 pandas.dataframe 时,它可以正常输出列!当我运行“traffic.head()”时,它可以正常运行!但是,当我运行“traffic.Stop_day”时,它表示 AttributeError 如下所示:
import odo
traffic=bl.Data(df)
print(traffic.fields)
['机构','子机构','描述','位置','纬度','经度','事故','腰带','人身伤害','财产损失','致命','商业许可证', 'HAZMAT', '商用车', '酒精', '工作区', '状态', 'VehicleType', '年份', '品牌', '型号', '颜色', '违规类型', ' Charge', 'Article', 'Contributed to Accident', 'Race', 'Gender', 'Driver City', 'Driver State', 'DL State', '逮捕类型', '地理位置', '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 in call (self, obj) 700 type_pprinters=self.type_printers, 701 deferred_pprinters=self.deferred_printers) - -> 702 打印机.pretty(obj) 703 打印机.flush() 704 返回 stream.getvalue()
e:\software\python36\lib\site-packages\IPython\lib\pretty.py in pretty(self, obj) 398 if cls is not object \ 399 and callable(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 in _repr_pprint(obj, p, cycle) 693 """一个只重定向到正常repr函数的pprint。""" 694 # Find换行符并将它们替换为 p.break_() --> 695 output = repr(obj) 696 for idx, output_line in enumerate(output.splitlines()): 697 if idx:
e:\software\python36\lib\site-packages\blaze\interactive.py in _choose_repr(self) 440 else: 441 warnings.warn(_warning_msg, DeprecationWarning, stacklevel=2) --> 442 return expr_repr(self) 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 return repr_tables(expr, 10) 361 362 # 小数组
e:\software\python36\lib\site-packages\blaze\interactive.py in repr_tables(expr, n) 240 241 def repr_tables(expr, n=10): --> 242 result = concrete_head(expr, n)。 rename(columns={None: ''}) 243 244 if isinstance(result, (DataFrame, Series)):
e:\software\python36\lib\site-packages\blaze\interactive.py in concrete_head(expr, n) 220 return odo(head, DataFrame) 221 else: --> 222 df = odo(head, DataFrame) 223 df .columns = [expr._name] 224 返回 df
e:\software\python36\lib\site-packages\odo\odo.py in odo(source, target, **kwargs) 89 odo.append.append - 将东西添加到现有的东西上 90 """ ---> 91返回(目标,源,**kwargs)
e:\software\python36\lib\site-packages\multipledispatch\dispatcher.py in call (self, *args, **kwargs) 276 self._cache[types] = func 277 try: --> 278 return func(* 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 in call (self, *args, **kwargs) 276 self._cache[types] = func 277 try: --> 278 return func(* args, **kwargs) 279 280 MDNotImplementedError 除外:
e:\software\python36\lib\site-packages\odo\into.py in Wrapped(*args, **kwargs) 41 raise TypeError('dshape argument is not an instance of DataShape') 42 kwargs['dshape'] = dshape ---> 43 return f(*args, **kwargs) 44 return Wrapped 45
e:\software\python36\lib\site-packages\odo\into.py in into_type(a, b, dshape, **kwargs) 51 如果 dshape 为无:52 dshape = discover(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 call (self, *args, **kwargs): ---> 44返回_transform(self.graph,*args,**kwargs)45 46
e:\software\python36\lib\site-packages\odo\core.py in _transform(graph, target, source, exclude_edges, ooc_types, **kwargs) 55 pth = path(graph, type(source), target, 56 exclude_edges=excluded_edges, ---> 57 ooc_types=ooc_types) 58 try: 59 for (A, B, f) in pth:
e:\software\python36\lib\site-packages\odo\core.py 在路径(图,源,目标,excluded_edges,ooc_types)92 pth = nx.shortest_path(g,源=源,目标=目标,权重= '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:“有向图”对象没有属性“边”
-------------------------------------------------- ------------------------- AttributeError Traceback(最近一次调用最后一次) e:\software\python36\lib\site-packages\IPython\core\ formatters.py in call (self, obj) 343 method = get_real_method(obj, self.print_method) 344 if method is not None: --> 345 return method() 346 return None 347 else:
e:\software\python36\lib\site-packages\blaze\interactive.py in _warning_repr_html(self) 448 else: 449 warnings.warn(_warning_msg, DeprecationWarning, stacklevel=2) --> 450 return to_html(self) 451 452
e:\software\python36\lib\site-packages\multipledispatch\dispatcher.py in call (self, *args, **kwargs) 276 self._cache[types] = func 277 try: --> 278 return func(* args, **kwargs) 279 280 MDNotImplementedError 除外:
e:\software\python36\lib\site-packages\blaze\interactive.py in to_html(expr) 387 如果不是 expr._resources() 或 ndim(expr) != 1: 388 返回 to_html(expr_repr(expr)) - -> 389 返回 to_html(concrete_head(expr)) 390 391
e:\software\python36\lib\site-packages\blaze\interactive.py in concrete_head(expr, n) 220 return odo(head, DataFrame) 221 else: --> 222 df = odo(head, DataFrame) 223 df .columns = [expr._name] 224 返回 df
e:\software\python36\lib\site-packages\odo\odo.py in odo(source, target, **kwargs) 89 odo.append.append - 将东西添加到现有的东西上 90 """ ---> 91返回(目标,源,**kwargs)
e:\software\python36\lib\site-packages\multipledispatch\dispatcher.py in call (self, *args, **kwargs) 276 self._cache[types] = func 277 try: --> 278 return func(* 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 in call (self, *args, **kwargs) 276 self._cache[types] = func 277 try: --> 278 return func(* args, **kwargs) 279 280 MDNotImplementedError 除外:
e:\software\python36\lib\site-packages\odo\into.py in Wrapped(*args, **kwargs) 41 raise TypeError('dshape argument is not an instance of DataShape') 42 kwargs['dshape'] = dshape ---> 43 return f(*args, **kwargs) 44 return Wrapped 45
e:\software\python36\lib\site-packages\odo\into.py in into_type(a, b, dshape, **kwargs) 51 如果 dshape 为无:52 dshape = discover(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 call (self, *args, **kwargs): ---> 44返回_transform(self.graph,*args,**kwargs)45 46
e:\software\python36\lib\site-packages\odo\core.py in _transform(graph, target, source, exclude_edges, ooc_types, **kwargs) 55 pth = path(graph, type(source), target, 56 exclude_edges=excluded_edges, ---> 57 ooc_types=ooc_types) 58 try: 59 for (A, B, f) in pth:
e:\software\python36\lib\site-packages\odo\core.py 在路径(图,源,目标,excluded_edges,ooc_types)92 pth = nx.shortest_path(g,源=源,目标=目标,权重= '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:“有向图”对象没有属性“边”
所以有什么问题?