Skip to main content

mean()

df.groupby(column_name).mean()

Returns a DataFrame, with rows as groups, and each column as the mean of the column values within each group.

Note:
Only for columns of type int or float, all other columns are automatically dropped.

pets
IndexSpeciesColorWeightAge
0dogblack405
1catgolden158
2catblack209
3dogwhite802
4dogblack250.5
5hamsterblack13
6hamstergolden0.250.2
pets.groupby('Species').mean()
IndexWeightAgeIs_Cat
cat8.83333333333.06666666671
dog48.33333333332.50
hamster0.6251.60