Skip to content
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

User-facing AssertionError with groupby on list of empty list. #5289

Closed
jtratner opened this issue Oct 21, 2013 · 5 comments · Fixed by #25589
Closed

User-facing AssertionError with groupby on list of empty list. #5289

jtratner opened this issue Oct 21, 2013 · 5 comments · Fixed by #25589
Labels
Error Reporting Incorrect or improved errors from pandas Groupby

Comments

@jtratner
Copy link
Contributor

I hesitate to post this, but grouping on a list of empty list yields an AssertionError. It's so edge case I'm not sure it's worth bring up though:

df = pd.DataFrame(zip(range(10), range(10)), columns=['apple', 'b'])
df.groupby([[]])
# Long traceback yields: AssertionError: Grouper and axis must be same length

Came from this SO issue (but it's really only related because of the error message) - http://stackoverflow.com/questions/19483991/how-to-make-grouper-and-axis-the-same-length

@ghost
Copy link

ghost commented Jan 24, 2014

What's the problem there? that seems like a reasonable assertion and a reasonable error message.

@jreback
Copy link
Contributor

jreback commented Jan 24, 2014

I think it should just be a ValueError, maybe a tad bit more informative..

@jreback jreback modified the milestones: 0.15.0, 0.14.0 Apr 9, 2014
@jreback jreback reopened this Nov 17, 2014
@jtratner
Copy link
Contributor Author

Oh I just closed it because I had opened it and it didn't seem particularly
important.

On Mon, Nov 17, 2014, 3:06 AM jreback notifications@github.com wrote:

Reopened #5289 #5289.


Reply to this email directly or view it on GitHub
#5289 (comment).

@simonjayhawkins
Copy link
Member

this issue can be closed.

original code sample raises ValueError on 0.25.0.dev0+208.g74a9ae309

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\generic.py", line 7672, in groupby
    observed=observed, **kwargs)
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\groupby\groupby.py", line 2206, in groupby
    return klass(obj, by, **kwds)
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\groupby\groupby.py", line 363, in __init__
    mutated=self.mutated)
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\groupby\grouper.py", line 605, in _get_grouper
    if not isinstance(gpr, Grouping) else gpr)
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\groupby\grouper.py", line 242, in __init__
    self.grouper = _convert_grouper(index, grouper)
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\groupby\grouper.py", line 632, in _convert_grouper
    raise ValueError('Grouper and axis must be same length')
ValueError: Grouper and axis must be same length

@simonjayhawkins
Copy link
Member

this issue can be closed.

although there is no coverage. maybe we should add a test first.

@gfyoung gfyoung removed this from the Contributions Welcome milestone Mar 7, 2019
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 Groupby
Projects
None yet
4 participants