Closed

Description
Since groupby.agg()
is, "by definition a reducer." (in other words, produces one value per series in a group), it seems odd that it accepts non-aggregating operations such as 'rank':
Related to #22509 (comment) where groupby.transform('rank')
applies the wrong code path to 'rank'
because it is treated as an aggregator (array->scalar) instead of a shape-preserving operation.
In [82]: df=pd.DataFrame(dict(price=[1,2,2,3,3,3],cost=(1,2,1,3,2,1)))
...: df
Out[82]:
price cost
0 1 1
1 2 2
2 2 1
3 3 3
4 3 2
5 3 1
In [83]: g=df.groupby('price')
...: g.agg('rank').astype(int)
Out[83]:
cost
0 1
1 2
2 1
3 3
4 2
5 1```
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
agg
vs.transform
#27389ghost commentedon Jul 14, 2019
superseded by #27389