-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
DEPR: groupby with as_index=False doesn't add grouper as column when passing a Series as group key #49519
Comments
Hmm, this seems to be a duplicate of #40591, which is mentioning the user guide (I only looked in the reference docs, where this is indeed no mentioned) |
Assuming that the implementation/performance isn't a barrier here (I can't imagine why it would be), +1 on always including the groupers when |
I've confirmed the implementation is rather straightforward here, but the deprecation less so. It is easy to reliably emit a warning the behavior will change when more groupers will be included in the future, however there is no way for users to adopt future behavior early, preserve old behavior when the change is made, nor silence the warning. I think we also can't call this purely a bug fix, it does appear in the documentation:
I wonder if this is a case to make a breaking change without deprecation. A few opinionated thoughts:
|
Actually, we can instruct users to use in-axis groupers in a deprecation warning. I'm in favor of deprecating this properly. |
I don't know if this is strictly speaking a but (the documentation doesn't really specify it), but I would have expected a different result:
(running with current main, 2.0.0.dev0+532.gdec9be2a5c)
When your key is a column in the DataFrame, specifying
as_index=False
will move the group key values to a column in the resulting dataframe:I would have expected the same behaviour if you pass the key as a Series.
cc @rhshadrach
This is related to #49450 (comment), where I encountered this behaviour for the case where the Series is actually a column of the original DataFrame (when changing this Series to be a view, and not an identical object).
The text was updated successfully, but these errors were encountered: