pandas how to sort dataframe after group by code example
Example 1: pandas sort values group by
df.groupby(['job']).apply(lambda x: (x.groupby('source')
.sum()
.sort_values('count', ascending=False))
.head(3))
Example 2: Group based sort pandas
df_scored.sort_values('Score', ascending= False).sort_index(level='Index1', sort_remaining=False)