pandas groupby and mean by group code example Example: pandas groupby mean df.groupby(['A', 'B']).mean()