Os pandas criam a média por grupo
df.groupby("ColumnNameOfGroups")["ColumnNameOfWhatToAvg"].mean()
Arno Deceuninck
df.groupby("ColumnNameOfGroups")["ColumnNameOfWhatToAvg"].mean()