Skip to main content

count()

df.groupby(column_name).count()

Returns a DataFrame, with rows as groups, and all columns as the number of rows in each group.

Note:
All columns have the same value. It is advised to drop and rename the columns.

pets
IndexSpeciesColorWeightAge
0dogblack405
1catgolden158
2catblack209
3dogwhite802
4dogblack250.5
5hamsterblack13
6hamstergolden0.250.2
pets.groupby('Species').count()
IndexIDColorWeightAge
cat2222
dog3333
hamster2222