Skip to content

Renaming an empty MultiIndex fails #14139

Closed
@chazmo03

Description

@chazmo03
s = pd.Series([0], index=pd.MultiIndex.from_tuples([('a', 1)]))

# This works:
s.rename(lambda x: x)

# This fails:
s.iloc[0:0].rename(lambda x: x)

Renaming an empty index should not throw an error. It should just return the original empty index. It appears to be failing because _transform_index calls MultiIndex.from_tuples, which doesn't accept an empty list of tuples.

I would imagine that this could instead call from_arrays, which from_tuples calls anyway, or it could check for the special case of an empty index.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions