Show my code
>>> df = pd.DataFrame({'key1': ['a', 'a', 'b', 'b', 'a'], \
'key2': ['one', 'two', 'one', 'two', 'one'], \
'data1': np.random.randn(5), \
'data2': np.random.randn(5)})
>>> new_df = df.groupby(['key1', 'key2']).mean().unstack()
>>> print new_df
data1 data2
key2 one two one two
key1
a -0.070742 -0.598649 -0.349283 -1.272043
b -0.109347 -0.097627 -0.641455 1.135560
>>> print new_df.columns
MultiIndex(levels=[[u'data1', u'data2'], [u'one', u'two']],
labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=[None, u'key2'])
As you can see, the MultiIndex dataframe is different with normal dataframes, so how to access the data in the MultiIndex dataframe.