【发布时间】:2019-11-24 15:03:20
【问题描述】:
我希望将嵌套的 JSON 转换为 pandas 的数据框。
我尝试使用 json_normalize(),但它不起作用。我尝试使用它,如this tutorial 所示。也许我定义的父节点不正确,因为我的 json 比示例更深入
with open(json_pathfile) as f:
data_json = json.load(f)
嵌套的 json 看起来像这样
{
"data": {
"allOpportunityApplication": {
"data": [
{
"person": {
"id": "659642",
"opportunity_applications_count": 13,
"status": "applied"
}
},
{
"person": {
"id": "3620882",
"opportunity_applications_count": 4,
"status": "applied"
}
},
...
使用时
flat_json = json_normalize(data_json['data'])
flat_json.head(3)
输出是单个单元格。
我希望有一个以id、opportunity_applications_count 和status 为列的数据框。
【问题讨论】:
标签: python json pandas dataframe google-colaboratory