【发布时间】:2018-10-09 11:41:41
【问题描述】:
我正在尝试使用 pd.read_json() 将亚马逊评论数据加载到 pandas 数据帧中,这是一个 JSON 文件,我收到以下错误 Unmatched ''"' when when decoding 'string'.我正在使用 jupyter notebook
数据格式:
{"reviewerID": "AGL65XWV7MH3C", "asin": "B003FMUVKO", "reviewerName": "William B. Bebout \"Acknud\"", "helpful": [0, 1], "reviewText": "Too short. I would have rated it higher if it was long enough to hold my attention! It did have significant violence but not much else.", "overall": 3.0, "summary": "Short", "unixReviewTime": 1304985600, "reviewTime": "05 10, 2011"}
Python 代码:
data =pd.read_json('sample_data.json', lines=True)
【问题讨论】:
-
@GeneBurinsky:我如何重新格式化它?,我刚刚显示了一行数据,在我的实际文件中,我有 1000 行
-
您的代码在我的笔记本电脑上运行良好
-
可能是您缺少转义反斜杠吗?尝试用“\\”替换所有“\”。
-
我用更少的行数执行了相同的代码,它对我有用,
-
这是数据错误,还是有办法使用 json.load() 参数解决?我遇到了同样的错误。
标签: python pandas jupyter-notebook