December 2018
Beginner to intermediate
682 pages
18h 1m
English
There are a few main flavors of syntax that you will encounter when performing an aggregation. The following four blocks of pseudocode summarize the main ways you can perform an aggregation with the groupby method:
>>> df.groupby(['grouping', 'columns']) \ .agg({'agg_cols1':['list', 'of', 'functions'], 'agg_cols2':['other', 'functions']})
>>> df.groupby(['grouping', 'columns'])['aggregating', 'columns'] \ .agg([aggregating, functions])