I have Datframe with Multiindex and I want to transfer it to Json
this is Datframe
This is the dataframe
When I try to convert it to JSON, and I put to_json() on the orient = index, it converts all the keys to tuple
That’s why I tried to put data in this format, but it didn’t know how to do it correctly
data = {
'2022-01-21': {
'SF1_8-1':
{"Lock_Auto":0,
"Lock_Man":0,
"lability_Auto":0,
"lability_Man":67499,
"ANd":40,
"ANR_Remove":0,
"AveI":11.01470647,
"AveLoss":113.8496936
},
'S01_8-2':
{"Lock_Auto":0,
"Lock_Man":0,
"Unavailability_Auto":0,
"Unavailability_Man":8475,
"ANd":40,
"ANR_Remove":0,
"AveI":11.01470647,
"AveLoss":113.8496936
},
'S01_8-3':
{"Lock_Auto":0,
"Lock_Man":0,
"Unavailability_Auto":0,
"Unavailability_Man":8475,
"ANd":40,
"ANR_Remove":0,
"AveI":11.01470647,
"AveLoss":113.8496936
}
},
'2022-01-22': {
'001_P87-1':
{"Lock_Auto":0,
"Lock_Man":0,
"Unavailability_Auto":0,
"Unavailability_Man":8475,
"ANd":40,
"ANR_Remove":0,
"AveI":11.01470647,
"AveLoss":113.8496936
},
},
'001_P-2':
{"Lock_Auto":0,
"Lock_Man":0,
"Unavailability_Auto":0,
"Unavailability_Man":8475,
"ANd":40,
"ANR_Remove":0,
"AveI":11.01470647,
"AveLoss":113.8496936
},
'001_P-3':
{"Lock_Auto":0,
"Lock_Man":0,
"Unavailability_Auto":0,
"Unavailability_Man":8475,
"ANd":40,
"ANR_Remove":0,
"AveI":11.01470647,
"AveLoss":113.8496936
},
}
- Question 1: Is there a way to transfer Multi_index Dataframe to Json
- Question 2: How can I put data like this?