Skip to content

BUG: assert_index_equal does not consider level order #53095

Open
@rhshadrach

Description

@rhshadrach

Ref: #53049 (comment)

The following does not raise:

index1 = pd.MultiIndex(levels=[['a', 'b']], codes=[[0, 1]])
index2 = pd.MultiIndex(levels=[['b', 'a']], codes=[[1, 0]])
tm.assert_index_equal(index1, index2)

In some sense, these indices are equal. However, levels is sometimes used as an order in certain ops, and if this is not consistently set then inconsistencies can arise. See #53009 for an example.

It seems to me that because of this, we should not consider these indices equal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexRelated to the Index class or subclassesNeeds DiscussionRequires discussion from core team before further actionTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions