I have a dataframe of this type:
d = {'a': [100,150,180,190]}
df = pd.DataFrame(data=d, index=[(2010,1) ,(2010,2 ), (2011,1) ,(2011,2 )])
Which returns
Out[91]:
a
(2010, 1) 100
(2010, 2) 150
(2011, 1) 180
(2011, 2) 190
My scope is to split the values in the index and make the dataframe more readable by preserving the information of the index. In other words, my expected outcome is this:
dd = {'a': [100,150,180,190], 'year': [2010, 2011, 2010,2011], 'class': [1,2, 1,2]}
df2 = pd.DataFrame(data=dd)
Out[92]:
a year class
0 100 2010 1
1 150 2011 2
2 180 2010 1
3 190 2011 2
Any help ?