【发布时间】:2017-04-03 19:30:36
【问题描述】:
我正在尝试在以下 pandas 数据框中解压缩嵌套的 JSON:
id info
0 0 [{u'a': u'good', u'b': u'type1'}, {u'a': u'bad', u'b': u'type2'}]
1 1 [{u'a': u'bad', u'b': u'type1'}, {u'a': u'bad', u'b': u'type2'}]
2 2 [{u'a': u'good', u'b': u'type1'}, {u'a': u'good', u'b': u'type2'}]
我的预期结果是:
id type1 type2
0 0 good bad
1 1 bad bad
2 2 good good
我一直在寻找其他解决方案,包括json_normalize,但不幸的是它对我不起作用。我应该把 JSON 当作一个字符串来得到我想要的吗?还是有更直接的方法来做到这一点?
【问题讨论】: