【发布时间】:2020-09-02 10:19:57
【问题描述】:
我有非常大的 json 数据,语法如下:
[
{
"origin": 101011001,
"destinations": [
{"destination": 101011001, "people": 7378},
{"destination": 101011002, "people": 120}
]
},
{
"origin": 101011002,
"destinations": [
{"destination": 101011001, "people": 754},
}
]
[在此处输入图片描述][1]
我的目标是将数据转换为 pandas 数据框,然后我想将其转换为 sql 以作为表存储在我的 postgresql 数据库中。
我想创建一个这样的熊猫数据框:
origin destination people
101011001 101011001 7378
101011001 101011002 120
101011002 101011001 754
现在,我只能使用 pandas.read_json() 获取列 'origin' 和 'destinations',其中 destinations 是一个包含目标值和人员值的列表。
如何实现上述数据框?
【问题讨论】:
标签: python sql json pandas dataframe