我制作了一个250MB的JSON文件,应该长成这个样子:
[ {"A":"uniquevalue0", "B":[1,2,3]},
{"A":"uniquevalue1", "B":[1]},
{"A":"uniquevalue2", "B":[1,2,3,4]} ]
"B"值可以是变量len>=1。 这个 表示我的JSON格式是有效的。
我调用
df = pandas.read_json('ut1.json', orient = 'records', dtype={"A":str, "B":list})
这里是文档。当读入到pandas dataframe中时,我得到了以下的回溯信息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/.../pandas/io/json.py", line 198, in read_json
date_unit).parse()
File "/.../pandas/io/json.py", line 266, in parse
self._parse_no_numpy()
File "/.../pandas/io/json.py", line 496, in _parse_no_numpy
loads(json, precise_float=self.precise_float), dtype=None)
ValueError: Unexpected character found when decoding 'true'
想不出哪里出了问题。抛出错误的Python文件没什么用。