-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
'mode' not recognized by df.groupby().agg(), but pd.Series.mode works #11562
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
Comments
Hmm, I guess this might be because pd.Series.mode() returns a series, not a scalar. So maybe I need my own mode that decides how to handle the multi-modal case, e.g. pd.Series.mode().mean() or whatever? |
Correct. IIRC there's an older issue about this, where we decided to keep our behavior of always returning a series, and not adding a flag to reduce if possible. I could be misremembering though. In these cases I'll usually just use scipy's
|
Here's a mini-example; could be like
|
What about when grouping Series? I have no issue with |
I encountered this problem and ended up settling for this: But yes, I agree with @kernc, I would not mind |
xref #19254 |
Closing as a duplicate of #19254 |
This works:
but this doesn't:
I thought all the series aggregate methods propagated automatically to groupby, but I've probably misunderstood?
The text was updated successfully, but these errors were encountered: