I got a directory in this form:
dict = {'Filter1':{'Method1':{'Fuction1':{'Value1': 1, 'Value2': 2},
'Fuction2':{'Value1': 1, 'Value2': 2}},
'Method2':{'Fuction1':{'Value1': 1, 'Value2': 2},
'Fuction2':{'Value1': 1, 'Value2': 2}}},
'Filter2':{'Method1':{'Fuction1':{'Value1': 1, 'Value2': 2},
'Fuction2':{'Value1': 1, 'Value2': 2}},
'Method2':{'Fuction1':{'Value1': 1, 'Value2': 2},
'Fuction2':{'Value1': 1, 'Value2': 2}}}}
and i want to create a Dataframe in this shape:
Filter1 Filter2
Method1 Method2 Method1 Method2
Function1 Value1 1 1 1 1
Value2 2 2 2 2
Function2 Value1 1 1 1 1
Value2 2 2 2 2
how do i do this? All the posts i could find were just refering to two subrows or subcolumns but never both. Thanks ahead guys!!
So far i tried this aproach:
df = pd.DataFrame.from_dict({(i, j): dict[i][j]
for i in dict.keys()
for j in dict[i].keys()
},
orient='index')
witch gave me this result:
Fuction1 Fuction2
Filter1 Method1 {'Value1': 1, 'Value2': 2} {'Value1': 1, 'Value2': 2}
Method2 {'Value1': 1, 'Value2': 2} {'Value1': 1, 'Value2': 2}
Filter2 Method1 {'Value1': 1, 'Value2': 2} {'Value1': 1, 'Value2': 2}
Method2 {'Value1': 1, 'Value2': 2} {'Value1': 1, 'Value2': 2}
but i want the row and the columns swaped and Value1 and Value2 as the rownames