I want to convert pandas dataframe to a key value pair dictionary by combining index and column name as key. Is there a easy way to do it?
Before:
T1 T2
apple 5 1
pear 2 1.5
banana 10 12
After:
{'apple_T1': 5,
'apple_T2': 1,
'pear_T1': 2,
...
'banana_T2':12
}
Thanks a lot!