I have a dictionary like this:
my_dict
{'metric_1-metric2': [0.062034245713139154,
0.7711299537484807,
0.9999999999999999,
['US', 'mobile', 'google'],
['UK', 'desktop', 'facebook']],
'metric_1-metric_3': [-0.9607689228305227,
-0.12803370313903312,
0.778375882191523,
['CAN', 'tablet', 'google'],
['UK', 'desktop', 'yahoo']],
'metric_1-metric_4': [-0.4678967355247944,
0.6600255030070277,
0.9999999999999999,
['PT', 'desktop', 'gmail'],
['UK', 'desktop', 'apple']]}
I am trying to achieve the following result:
df
A B C D E F G
metric_1 metric_2 0.062 0.771 0.999 ['US', 'mobile', 'google'] ['UK', 'desktop', 'facebook']
metric_1 metric_3 -0.960 -0.128 0.778 ['CAN', 'tablet', 'google'] ['UK', 'desktop', 'yahoo']
metric_1 metric_4 -0.467 0.660 0.999 ['PT', 'desktop', 'gmail'] ['UK', 'desktop', 'apple']
It's clear that I'll split up the names of the key in my_dict:
index_names = []
column_names = []
for x in my_dict.keys():
index_names.append(x.split('-')[0])
column_names.append(x.split('-')[1])
How could I create such a structure in a pandas dataframe?