Использовать метод size ():
import pandas as pd print df.groupby['category'].size() #where df is your dataframe