【发布时间】:2021-05-12 14:31:19
【问题描述】:
我有一个如下所示的 JSON 文件,我怎样才能用它制作一个数据框。我想将主键设为索引,将子键设为列。
{
"PACK": {
"labor": "Recycle",
"actual": 0,
"Planned": 2,
"max": 6
},
"SORT": {
"labor": "Mix",
"actual": 10,
"Planned": 4,
"max": 3
}
}
预期的输出类似于,我尝试使用 df.T 但不起作用。对此的任何帮助表示赞赏。
actual planned
PACK 0 2
SORT 10 4
【问题讨论】:
-
请显示当前代码
-
我做了 df1 = pd.json_normalize(df) 并且它给了我 1 行子键作为列