SyntaxFix
Write A Post
Hire A Developer
Questions
Do your groupby, and use reset_index() to make it back into a DataFrame. Then sort.
grouped = df.groupby('mygroups').sum().reset_index() grouped.sort_values('mygroups', ascending=False)