我有一个如下数据框:
House hexNum Name ID1 ID2 DPD Time1 Time2 P1 Pr1 Pr2 Addr hex2 bool1 bool2 bool3 path
Momma 0x0000000002a71c89 Matt 123 10 0x12 2016-05-18 17:20:57 UTC+0000 2016-05-18 17:20:57 UTC+0000 1555 19 NDN 555.18 0xa1900000 True True False /mnt/c/dir1/thing2
Momma 0x0000000002a71c89 Matt 123 10 0x12 2016-05-18 17:20:57 UTC+0000 2016-05-18 17:20:57 UTC+0000 1555 19 NDN 555.18 0xa2000000 True False False /mnt/c/dir1/thing3
Momma 0x0000000002a71c89 Matt 123 10 0x12 2016-05-18 17:20:57 UTC+0000 2016-05-18 17:20:57 UTC+0000 1555 19 NDN 555.18 0xa2100000 False True False /mnt/c/dir1/thing4
Dadda 0x0000000002a71c90 Adam 124 10 0x13 2016-05-18 17:20:57 UTC+0000 NaN 1533 19 NDA 123.23 0xb2800000 True False False /mnt/c/dir1/thing2
Dadda 0x0000000002a71c90 Adam 124 10 0x13 2016-05-18 17:20:57 UTC+0000 NaN 1533 19 NDA 123.23 0xb2900000 True False True /mnt/c/dir2/thing3
Dadda 0x0000000002a71c90 Adam 124 10 0x13 2016-05-18 17:20:57 UTC+0000 NaN 1533 19 NDA 123.23 0xb3000000 True False False /mnt/c/dir2/thing4
如何转换为嵌套的json输出,如下所示?我已经尝试过这里的方法" Pandas Dataframe to Nested JSON"。这似乎它会做我正在寻找但我在第二个巢和其他数据有一些困难。任何帮助,将不胜感激。
[
{"House":"Momma",
{"Name": "Matt",
"Name Properties": [{
"hexNum":"0x0000000002a71c89",
"ID1":123,
"ID2":10,
"DPD":0x12,
"Time1":"2010-05-18 17:20:57 UTC+0000",
"Time2":"2016-05-18 17:20:57 UTC+0000",
"Addr Properties":{
"Addr":555.18,
"P1":1555,
"Pr1":19,
"Pr2":"NDN"},
"Path": [
{"/mnt/c/dir1/thing2":{"hex2":"0xa1900000","bool1":True,"bool2":True,"bool3":False}},
{"/mnt/c/dir1/thing2":{"hex2":"0xa1900000","bool1":True,"bool2":True,"bool3":False}},
{"/mnt/c/dir1/thing2":{"hex2":"0xa1900000","bool1":True,"bool2":True,"bool3":False}}
]
}]
},
},
{"House":"Dadda",
{"Name": "Adam",
"Name Properties": [{
"hexNum":"0x0000000002a71c89",
"ID1":123,
"ID2":10,
"DPD":0x12,
"Time1":"2010-05-18 17:20:57 UTC+0000",
"Time2":"2016-05-18 17:20:57 UTC+0000",
"Addr Properties":{
"Addr":555.18,
"P1":1555,
"Pr1":19,
"Pr2":"NDN"},
"Path": [
{"/mnt/c/dir1/thing2":{"hex2":"0xa1900000","bool1":True,"bool2":True,"bool3":False}},
{"/mnt/c/dir1/thing2":{"hex2":"0xa1900000","bool1":True,"bool2":True,"bool3":False}},
{"/mnt/c/dir1/thing2":{"hex2":"0xa1900000","bool1":True,"bool2":True,"bool3":False}}
]
}]
}
}
]