我正在尝试将下面的 JSON 结构读入 pandas dataframe,但它会抛出错误消息:
ValueError:将 dicts 与非 Series 混合可能会导致排序不明确。
json 数据:
{
"status": {
"statuscode": 200,
"statusmessage": "Everything OK"
},
"result": [{
"id": 22,
"club_id": 16182
}, {
"id": 23,
"club_id": 16182
}, {
"id": 24,
"club_id": 16182
}, {
"id": 25,
"club_id": 16182
}, {
"id": 26,
"club_id": 16182
}, {
"id": 27,
"club_id": 16182
}]
}
我怎样才能做到这一点?我已经尝试了下面的脚本...
j_df = pd.read_json('json_file.json')
j_df
with open(j_file) as jsonfile:
data = json.load(jsonfile)
如果您只需要 dataframe 中的结果部分,那么这里的代码可以帮助您。
import json
import pandas as pd
data = json.load(open('json_file.json'))
df = pd.DataFrame(data["result"])