Skip to content

Commit 032c590

Browse files
authored
DOC: added example of valid input dict in dfgroupby.aggregate (#47317)
* DOC: added example of valid input dict in dfgroupby.aggregate * Updated line spacing to pass flake8 test * Removed trailing whitespace * retrying tests * Rerun tests * added user-defined function to examples * Update generic.py
1 parent 38a7d29 commit 032c590

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/core/groupby/generic.py

+8
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,14 @@ class DataFrameGroupBy(GroupBy[DataFrame]):
814814
1 1 2
815815
2 3 4
816816
817+
User-defined function for aggregation
818+
819+
>>> df.groupby('A').agg(lambda x: sum(x) + 2)
820+
B C
821+
A
822+
1 5 2.590715
823+
2 9 2.704907
824+
817825
Different aggregations per column
818826
819827
>>> df.groupby('A').agg({'B': ['min', 'max'], 'C': 'sum'})

0 commit comments

Comments
 (0)