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

Segfault in .groupby() with empty groups #1048

Closed
twiecki opened this issue Apr 13, 2012 · 2 comments

Comments

@twiecki
Copy link
Contributor

commented Apr 13, 2012

I get a segfault when running:

pandas.DataFrame([1,2,3]).groupby([]).groups

As an aside, in my scenario (which I don't know how general it is) the user can supply the grouping. If no grouping should take place (i.e. groupby([])) I would like .groupby() to return the whole data, instead there is a:

/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.pyc in _get_compressed_labels(self)
547 group_index = get_group_index(all_labels, self.shape)
548 else:
--> 549 group_index = all_labels[0]
550 comp_ids, obs_group_ids = _compress_group_index(group_index)
551 return comp_ids, obs_group_ids

IndexError: list index out of range

I'm not sure whether it would be sensible to change the behavior so that the whole DataFrame is returned, but to me it would be more useful than raising an error.

@cdeil

This comment has been minimized.

Copy link

commented Apr 14, 2012

I just updated to 9385b62 and now also see a segfault when running the tests:

test_aggregate_item_by_item (pandas.tests.test_groupby.TestGroupBy) ... Segmentation fault: 11

as well as when running this line of code

pandas.DataFrame([1,2,3]).groupby([]).groups
@wesm

This comment has been minimized.

Copy link
Member

commented May 7, 2012

Now raise ValueError in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.