pd.groupby.mean by as columns code example Example: pandas groupby mean df.groupby(['A', 'B']).mean()