Skip to content

sort_index doesn't work after concat #15622

Closed
@mwiebusch78

Description

@mwiebusch78

The sort_index method does not seem to work properly if the dataframe was created with concat. See this example:

>>> df = pd.DataFrame(index=['a', 'b'])
>>> pd.concat([df, df], keys=[0.8, 0.5]).sort_index()
Empty DataFrame
Columns: []
Index: [(0.8, a), (0.8, b), (0.5, a), (0.5, b)]

The 0.5 tuples should come before the 0.8 ones. Everything works fine if I create the multi-index from a product:

>>> pd.DataFrame(index=pd.MultiIndex.from_product([[0.8, 0.5], ['a', 'b']]))
Empty DataFrame
Columns: []
Index: [(0.8, a), (0.8, b), (0.5, a), (0.5, b)]
>>> pd.DataFrame(index=pd.MultiIndex.from_product([[0.8, 0.5], ['a', 'b']])).sort_index()
Empty DataFrame
Columns: []
Index: [(0.5, a), (0.5, b), (0.8, a), (0.8, b)]

I'm on pandas version 0.18.1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions