Menu
CoddyTech

Recap: Top Products

Part of the Data and Plots section of Coddy's Machine Learning journey. Lesson 41 of 60.

challenge icon

Challenge

Medium

Remember the garden top 3 that opened this chapter? Now you build it, for an online shop and any category. products.csv has the columns product, category, price and sold (items sold this month). The program reads a category into category.

  1. Load products.csv.
  2. Add a column revenue: price times items sold.
  3. Keep the products of that category.
  4. Sort them by revenue, largest first.
  5. Print the top 3, with only product and revenue.

For another shop and the category garden:

  product  revenue
1    Hose     1500
2   Seeds      800
0    Rake      600

Try it yourself

import pandas as pd

category = input()

# Write your code below

All lessons in Data and Plots

Practice on your own: Online Python compiler