0
我有一个JSON文件看起来像:JSON堆叠数据帧
[
{
"id" : "abc",
"mood" : "happy",
"scores" : [
10,
15,
20
]
},
{
"id" : "def",
"mood" : "happy",
"scores" : [
103,
150,
200
]
},
{
"id" : "ghi",
"mood" : "sad",
"scores" : [
1,
15,
20,
45,
600,
1400
]
},
{
"id" : "jkl",
"mood" : "sad",
"scores" : [
10,
100,
1000,
10000
]
}
]
我敢试图得到了多层数据帧,看起来像:
id mood score
0 abc happy 10
1 abc happy 15
2 abc happy 20
3 def happy 103
...
14 jkl sad 10
15 jkl sad 100
等
但是,当我将JSON对象粘贴到数据框中时,我总是会得到一些变化:
其中“分数”列是列表。我已经搜索了很长时间,很难找到一个例子,但无法弄清楚如何将列表解压缩到我想要的格式。
对此提出建议?
除了我的回答,[这个苏答案(http://stackoverflow.com/questions/21160134/flatten-a -column-with-value-of-type-list-while-duplicating-the-other-columns-va)似乎可能是相关的。 – jme