Using the groupby function in a data frame