gpt4 book ai didi

python - 我能够读取文件,但无法在 Google Colab 上看到结果

转载 作者:行者123 更新时间:2023-12-04 02:27:37 25 4
gpt4 key购买 nike

df01 = pd.read_json('/content/drive/MyDrive/project/rio_bq_2019000000000000',lines=True)
此行没有错误。但是下一行有错误,我不明白这里发生了什么。我在 google colab 上阅读的
df01
我收到如下错误:
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/IPython/core/formatters.py in __call__(self, obj)
336 method = get_real_method(obj, self.print_method)
337 if method is not None:
--> 338 return method()
339 return None
340 else:

1 frames
/usr/local/lib/python3.7/dist-packages/pandas/io/formats/format.py in to_html(self, buf, encoding, classes, notebook, border)
986 notebook : {True, False}, optional, default False
987 Whether the generated HTML is for IPython Notebook.
--> 988 border : int
989 A ``border=border`` attribute is included in the opening
990 ``<table>`` tag. Default ``pd.options.display.html.border``.

AttributeError: 'NotebookFormatter' object has no attribute 'get_result'
Building Level ... lng localtime
0 TPS1 Level 2 ... -43.249902 2019-08-01 02:52:33.289 UTC
1 TPS1 Level 2 ... -43.250474 2019-08-01 02:52:35.488 UTC
2 TPS1 Level 2 ... -43.251573 2019-08-01 02:52:36.268 UTC
3 TPS1 Level 2 ... -43.249719 2019-08-01 02:52:41.537 UTC
4 TPS1 Level 2 ... -43.249737 2019-08-01 02:52:41.538 UTC
... ... ... ... ... ...
3372900 TPS1 Level 2 ... -43.250513 2019-08-25 10:21:01.483 UTC
3372901 TPS1 Level 2 ... -43.250169 2019-08-25 10:21:02.024 UTC
3372902 TPS1 Level 2 ... -43.250169 2019-08-25 10:21:02.026 UTC
3372903 TPS1 Level 2 ... -43.249944 2019-08-25 10:21:02.536 UTC
3372904 TPS1 Level 2 ... -43.249944 2019-08-25 10:21:02.536 UTC
我可以看到数据导入到 df01 中,如错误输出底部所示。但我不能使用它。为什么?我怎样才能解决这个问题?
如果您需要,这是我的示例数据文件
 {"Building":"TPS2","Level":"Level 3","ClientMacAddr":"8c:8e:f2:7d:2f:de","lat":-22.813377029213196,"lng":-43.247283256092494,"localtime":"2019-11-28 17:49:00.753 UTC"}
{"Building":"TPS2","Level":"Level 3","ClientMacAddr":"8c:8e:f2:7d:2f:de","lat":-22.813377029213196,"lng":-43.247283256092494,"localtime":"2019-11-28 17:49:00.753 UTC"}
{"Building":"TPS2","Level":"Level 3","ClientMacAddr":"00:27:15:00:10:1f","lat":-22.814628521677054,"lng":-43.24741506118599,"localtime":"2019-11-28 17:49:01.58 UTC"}
{"Building":"TPS2","Level":"Level 3","ClientMacAddr":"00:27:15:00:10:1f","lat":-22.814628521677054,"lng":-43.24741506118599,"localtime":"2019-11-28 17:49:01.58 UTC"}
在这之前我只有两行
import pandas as pd
drive.mount("/content/drive")

最佳答案

我仍然不知道发生了什么。但我只是弄清楚自己
在这种情况下,我只能使用 print 进行输出
就像 df01 在 jupyter 中运行良好,但在 google lab 中我只能写在 print(df01)
如果您遇到此错误

AttributeError: 'NotebookFormatter' object has no attribute 'get_result'
请在您要输出的每一行中添加 print()

关于python - 我能够读取文件,但无法在 Google Colab 上看到结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66412776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com