Each row in my DataFrame is a user vote entry for a restaurant. The data look like
id cuisine
91 american
3 american
91 american
233 cuban
233 cuban
2 cuban
where id refers to the restaurant.
I want to get something like the following
american 91 100
3 30
12 10
cuban 233 80
2 33
mexican 22 99
8 98
21 82
where the 2nd column is the id, and the 3rd column is the number of rows in the DataFrame for that id. In other words, sort by the number of rows, but group by cuisine. I tried
g = df.groupby(['cuisine', 'id'])
c = g.size().sort_values(ascending=False)
But the order of the cuisines is mixed.