Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TomAugspurger opened this issue Mar 28, 2014 · 0 comments · Fixed by #6849
Closed

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

TomAugspurger opened this issue Mar 28, 2014 · 0 comments · Fixed by #6849
Labels
Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@TomAugspurger
Copy link
Contributor

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.

@TomAugspurger TomAugspurger changed the title [ERR]: Better error message on unstack with non-unique index names [API/ERR]: Better error message on unstack with non-unique index names Mar 28, 2014
@jreback jreback added this to the 0.14.0 milestone Apr 5, 2014
TomAugspurger pushed a commit to TomAugspurger/pandas that referenced this issue Apr 9, 2014
Should raise a ValueError when (un)stacking a DataFrame
on a nonunique level. Previous behavior was to raise
a KeyError (not deliberately). Closes pandas-dev#6729.
TomAugspurger pushed a commit to TomAugspurger/pandas that referenced this issue Apr 9, 2014
Should raise a ValueError when (un)stacking a DataFrame
on a nonunique level. Previous behavior was to raise
a KeyError (not deliberately). Closes pandas-dev#6729.
jeffreystarr pushed a commit to jeffreystarr/pandas that referenced this issue Apr 28, 2014
Should raise a ValueError when (un)stacking a DataFrame
on a nonunique level. Previous behavior was to raise
a KeyError (not deliberately). Closes pandas-dev#6729.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
2 participants