Skip to content

Indexing a multi-index does not respect order of list indexer #10710

Closed
@jorisvandenbossche

Description

@jorisvandenbossche
In [40]: cols = pd.MultiIndex.from_product([['A', 'B', 'C'],[1,2]])

In [41]: df = pd.DataFrame(np.random.randn(5,6), columns=cols)

In [42]: df.loc[:, ['B', 'A']]
Out[42]:
          A                   B
          1         2         1         2
0 -0.990868  1.577803  1.023247 -0.423165
1 -1.180170  1.236143 -1.484085  0.044929
2  1.665502 -0.711081  0.227827  0.651859
3 -0.659154  0.154327 -1.548650 -0.070550
4 -0.232819  0.100959 -0.102296  0.260816

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions