SpinTheMic
Pro

Interview practice question

Top five products per category

Data Analyst · Python and Pandas · Beginner

How do you get the top five products by sales in each category using pandas?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Aggregate sales per product+category.
  • sort_values then groupby().head(5).
  • Or groupby().nlargest.
  • Or rank within group.
  • Handle ties deliberately.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics