Skip to content

[API/ERR]: Better error message on unstack with non-unique index names #6729

Closed
@TomAugspurger

Description

@TomAugspurger
df = pd.DataFrame([1,1], index=pd.MultiIndex.from_tuples([('a', 'a'), ('a', 'b')], names=['i1', 'i1']))

In [5]: df.unstack('i1')

...

KeyError: 'Level i1 not found'

I can do a PR later.

Should also probably be a ValueError instead of a KeyError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions