median mean in pandas using groupby code example Example: pandas groupby mean df.groupby(['A', 'B']).mean()