sort the pandas dataframe using groupby and create new dataframe code example
Example: pandas sort values group by
df.groupby(['job']).apply(lambda x: (x.groupby('source')
.sum()
.sort_values('count', ascending=False))
.head(3))