-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
DEPR: group by one element list gets scalar keys #59179
DEPR: group by one element list gets scalar keys #59179
Conversation
I deprecated the behavior for
@rhshadrach, could you please advise me on how to fix this test? |
pandas/core/groupby/grouper.py
Outdated
if not self.key_dtype_str: | ||
warnings.warn( | ||
"`groups` by one element list returns scalar is deprecated " | ||
"and will be removed. In a future version `groups` by one element " | ||
"list will return tuple. Use ``df.groupby(by='a').groups`` " | ||
"instead of ``df.groupby(by=['a']).groups`` to avoid this warning", | ||
FutureWarning, | ||
stacklevel=find_stack_level(), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to GroupBy.groups
? Then you won't need to modify Grouping
(e.g. include extra arguments) at all.
Sorry for the delay! I believe you've resolved this, let me know if not. |
Thanks @rhshadrach for reviewing this PR. I moved the FutureWarning from Grouping to GroupBy.groups as you suggested and added a note to v3.0.0. Could you please take a look at my changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thanks @natmokval! |
changed the behavior: group
keys
to be1-tuples
instead ofscalar
when grouping with alength-1 list