I’ve searched through SO and can’t seem to find a question that quite covers my particular case (if I’ve missed it – please let me know!)

I’ve got data structured like the image below:

There’s a lot of data so I need to avoid creating new columns (not if there’s a more efficient way!)

I’ve grouped it by ‘Name’ and ‘Result’ and used Size():

df = df.groupby([‘Name’,’Result’]).size().sort_values(ascending = False)

which sorts simply on the ‘Name’ column giving me this (and the graph below when I plot it using matplotlib)

The dataframe is sorted by the ‘Name’ column. How would I sort it by the sum of each Name’s grouped values (descending order). In this case since Sandy has 4 results, Adam 3, Meg 3 and Toby 2:

And which would consquently plot like this:

Source: Python Questions