-
-
Notifications
You must be signed in to change notification settings - Fork 19k
Closed
Labels
ApplyApply, Aggregate, Transform, MapApply, Aggregate, Transform, MapDuplicate ReportDuplicate issue or pull requestDuplicate issue or pull requestEnhancementGroupby
Description
This works:
df = pd.DataFrame({'A': [1, 2, 1, 2, 1, 2, 3], 'B': [1, 1, 1, 2, 2, 2, 2]})
df.groupby('B').agg(pd.Series.mode)
but this doesn't:
df.groupby('B').agg('mode')
...
AttributeError: Cannot access callable attribute 'mode' of 'DataFrameGroupBy' objects, try using the 'apply' method
I thought all the series aggregate methods propagated automatically to groupby, but I've probably misunderstood?
adamjstewart, joseortiz3, 07571026, DulceGracia, yohei741 and 6 more
Metadata
Metadata
Assignees
Labels
ApplyApply, Aggregate, Transform, MapApply, Aggregate, Transform, MapDuplicate ReportDuplicate issue or pull requestDuplicate issue or pull requestEnhancementGroupby