pandas get mean as column for group code example Example: pandas groupby mean df.groupby(['A', 'B']).mean()