(我无法编辑这个静止的标题:Add an array to a DataFrame我认为我没有标题的答案......我希望这可以帮助)
我正在阅读来自不同的.csv的信息,我需要将其转换为.json
1.csv是:
field1:1value1,field2:1value2,field3:1value3
2.csv有很多行,我必须按1value3过滤
row1field1:2value1,row1field2:2value2,row1field3:1value3,row1field4:3.csv,row2field1:2value4,row2field2:2value5,row2field3:1value3,row2field4:4.csv,
3.csv是:
field1:3value1,field2:3value2
4.csv是:
field1:4value1,field2:4value2
我需要我的最终json看起来像:
{
"field1": "1value1",
"field2": "1value2",
"field3": "1value3",
"talbes": [
{
"row1field1": "2value1",
"row1field2": "2value2",
"row1field3": "1value3",
"fieldsFromTable": [
{
"field1": "3value1",
"field2": "3value2"
}
]
},
{
"row2field1": "2value4",
"row1field2": "2value5",
"row1field3": "1value3",
"fieldsFromTable": [
{
"field1": "4value1",
"field2": "4value2"
}
]
}
]
}
我尝试使用dataFrame进行转换后使用dataFrame.to_json(),但我无法实现将dataFrame数组存储到其他数据帧中...而且我真的不知道哪个更好aprox to it。
由于
(我知道这个解释有点乱......对不起)