Skip to content

BUG: df.rename raises when multiindex has duplicates #38015

Closed
@GYHHAHA

Description

@GYHHAHA
>>> idx = pd.Index([('A','cat'),('B','cat'),('B','cat')])
>>> df = pd.DataFrame(index=idx)
>>> df.rename(index={'A':'Apple'}, level=0)
ValueError: non-broadcastable output operand with shape (1,1) doesn't match the broadcast shape (1,2)

Metadata

Metadata

Assignees

Labels

IndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndexNeeds TestsUnit test(s) needed to prevent regressionsgood first issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions