python dataframe average by group by column name code example Example: pandas groupby mean df.groupby(['A', 'B']).mean()