wesm/pandas — Issue #689: concat over MultiIndex does not hierarchify further
Author: twiecki
Created: 2012-01-26 15:59:50+00:00
State: open

df2
Out[62]:
A B C D
level1a 0 foo one -0.3364 -1.212780
1 bar one 1.5044 0.832076
level1b 2 foo two 0.1210 -0.547690
3 bar three -0.6163 0.948797
level1c 4 foo two 0.4783 -1.295089
5 bar two -0.6558 -1.515122
level1d 6 foo one -1.1923 -0.884387
7 foo three -0.6004 0.003952

pd.concat([df2[0:4], df2[4:8]], keys=['level0a', 'level0b'])
Out[66]:
A B C D
level0a level1a 0 foo one -0.3364 -1.212780
1 bar one 1.5044 0.832076
level0a level1b 2 foo two 0.1210 -0.547690
3 bar three -0.6163 0.948797
level0b level1c 4 foo two 0.4783 -1.295089
5 bar two -0.6558 -1.515122
level0b level1d 6 foo one -1.1923 -0.884387
7 foo three -0.6004 0.003952

While I would expect that there are only one of level0a and level0b at the first level.