Skip to main content

median()

df.groupby(column_name).median()

Returns a DataFrame, with rows as groups, and each column as the median 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').median()
IndexWeightAgeIs_Cat
cat100.21
dog4020
hamster0.6251.60