Skip to content

BUG: MultiIndex.append now drops names if not the same #54303

Open
@attack68

Description

@attack68

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

m1 = pd.MultiIndex.from_tuples([("a", 1)], names=["str", "int"])
m2 = pd.MultiIndex.from_tuples([("b", 2)])

m1.append(m2)

Issue Description

On previous pandas versions the names arg from m1 was maintained when m2 was appended that had no names.

On 2.0.3 the names are dropped from the return. Caught this in tests of a package upgrade.

Is this a bug or was this intentional - I can see arguments for both cases?

Expected Behavior

?

Installed Versions

Replace this line with the output of pd.show_versions()

Metadata

Metadata

Assignees

No one assigned

    Labels

    IndexRelated to the Index class or subclassesMultiIndex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions