0

I'm trying to list the movies with the most number of ranking for each occupation. This is what I did:

most_rated_occ =lens.groupby(['occupation','title']).size().sort_values(ascending=False).to_frame()

And the result looks like this:

result

But now, I want each group to be shown up to 10 movies each. Top 10 items for student, top 4 items for lawyer(because there are less then 10 movies in the lawyer group) and so on. Any ideas on how to approach?

most_rated_occ =lens.groupby(['occupation','title']).head(10).size().sort_values(ascending=False).to_frame()

But it says TypeError: 'numpy.int32' object is not callable.

kayak
  • 47
  • 4

0 Answers0