阅读 JSON
可以将 json 的字符串或文件路径传递给具有有效 json 的文件
In [99]: pd.read_json('[{"A": 1, "B": 2}, {"A": 3, "B": 4}]')
Out[99]:
A B
0 1 2
1 3 4
另外,为了节省内存:
with open('test.json') as f:
data = pd.DataFrame(json.loads(line) for line in f)
In [99]: pd.read_json('[{"A": 1, "B": 2}, {"A": 3, "B": 4}]')
Out[99]:
A B
0 1 2
1 3 4
另外,为了节省内存:
with open('test.json') as f:
data = pd.DataFrame(json.loads(line) for line in f)