Skip to content

ERR: better error reporting for passing list to level grouper on non-MultiIndex #9790

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
eXcuvator opened this issue Apr 2, 2015 · 3 comments · Fixed by #30646
Closed

ERR: better error reporting for passing list to level grouper on non-MultiIndex #9790

eXcuvator opened this issue Apr 2, 2015 · 3 comments · Fixed by #30646
Labels
good first issue Needs Tests Unit test(s) needed to prevent regressions
Milestone

Comments

@eXcuvator
Copy link

groupy(level=[0]) doesn't work on a unique index. I guess it is semantics whether one allows not only level=0, but also level=[0], but if not, the error message should be different:

df = pd.DataFrame(np.arange(0,9).reshape(3,3))
df.groupby(level=[0])
ValueError: level > 0 only valid with MultiIndex
@jreback jreback added the Error Reporting Incorrect or improved errors from pandas label Apr 2, 2015
@jreback jreback added this to the Next Major Release milestone Apr 2, 2015
@jreback jreback added the Groupby label Apr 2, 2015
@jreback jreback changed the title SingleIndex and Groupby ERR: better error reporting for passing list to level grouper on non-MultiIndex Apr 2, 2015
@ron819
Copy link

ron819 commented Sep 20, 2018

Any chance this will be fixed soon?

@jreback
Copy link
Contributor

jreback commented Sep 20, 2018

a community pull request would make this happen

@mroeschke
Copy link
Member

mroeschke commented Oct 26, 2019

This looks to work on master, as the operation is okay and shouldn't raise and error I suppose. Could use a test.

In [72]: df = pd.DataFrame(np.arange(0,9).reshape(3,3))
    ...: df.groupby(level=[0]).mean()
Out[72]:
   0  1  2
0  0  1  2
1  3  4  5
2  6  7  8

In [73]: df = pd.DataFrame(np.arange(0,9).reshape(3,3))
    ...: df.groupby(level=0).mean()
Out[73]:
   0  1  2
0  0  1  2
1  3  4  5
2  6  7  8

In [74]: pd.__version__
Out[74]: '0.26.0.dev0+682.g08ab156eb'

@mroeschke mroeschke added good first issue Needs Tests Unit test(s) needed to prevent regressions and removed Error Reporting Incorrect or improved errors from pandas Groupby labels Oct 26, 2019
@simonjayhawkins simonjayhawkins modified the milestones: Contributions Welcome, 1.0 Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants