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

Fix groupby.get_group with length-1 tuple with list-like grouper #17216

Merged
merged 3 commits into from
Oct 31, 2024

Conversation

mroeschke
Copy link
Contributor

Description

closes #17187

Adds similar logic as implemented in pandas: https://github.com/pandas-dev/pandas/blob/main/pandas/core/groupby/groupby.py#L751-L758

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke added bug Something isn't working Python Affects Python cuDF API. non-breaking Non-breaking change labels Oct 30, 2024
@mroeschke mroeschke requested a review from a team as a code owner October 30, 2024 23:30
@mroeschke mroeschke requested review from vyasr and isVoid October 30, 2024 23:30
@mroeschke
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit a83debb into rapidsai:branch-24.12 Oct 31, 2024
102 checks passed
@mroeschke mroeschke deleted the bug/gb/get_group branch October 31, 2024 19:38
Comment on lines +484 to +488
if is_list_like(self._by):
if isinstance(name, tuple) and len(name) == 1:
name = name[0]
else:
raise KeyError(name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey - was this missing a if is_list_like(self._by) and len(self._by) ==1?

rapids-bot bot pushed a commit that referenced this pull request Dec 23, 2024
)

#17216 added similar logic to what's in pandas https://github.com/pandas-dev/pandas/blob/602ae10f3d0d599ebbdd151e8a09f0baf20b4637/pandas/core/groupby/groupby.py#L787-L794, but missed one crucial ingredient: checking that the length of the keys is `1` before raising

Authors:
  - Marco Edward Gorelli (https://github.com/MarcoGorelli)
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #17653
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[BUG] get_group raises with length-1 tuple when grouping by length-1 list
3 participants