我这样将json文件从Google驱动器导入到Colab
downloaded = drive.CreateFile({'id':'XXX'}) 已下载.GetContentFile('All_Beauty.json')
当我尝试使用
读取文件时import pandas as pd
beauty_df = pd.read_json('All_Beauty.json')
beauty_df.head()
我收到此错误:
ValueError Traceback (most recent call last)
<ipython-input-15-1acb00f4feed> in <module>()
----> 1 beauty_df = pd.read_json('All_Beauty.json')
2 beauty_df.head()
5 frames
/usr/local/lib/python3.6/dist-packages/pandas/io/json/_json.py in _parse_no_numpy(self)
1087 if orient == "columns":
1088 self.obj = DataFrame(
-> 1089 loads(json, precise_float=self.precise_float), dtype=None
1090 )
1091 elif orient == "split":
ValueError: Trailing data
有什么问题的想法吗?非常感谢
答案 0 :(得分:0)
听起来您的json文件中有几行。
您可能需要使用lines
参数:
beauty_df = pd.read_json('All_Beauty.json', lines=True)