Skip to content

concat over MultiIndex does not hierarchify further #689

@twiecki

Description

@twiecki
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions