Recap: Top Products
Part of the Data and Plots section of Coddy's Machine Learning journey. Lesson 41 of 60.
Challenge
MediumRemember 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.
- Load
products.csv. - Add a column
revenue: price times items sold. - Keep the products of that category.
- Sort them by revenue, largest first.
- Print the top 3, with only
productandrevenue.
For another shop and the category garden:
product revenue
1 Hose 1500
2 Seeds 800
0 Rake 600Try it yourself
import pandas as pd
category = input()
# Write your code below
All lessons in Data and Plots
2NumPy Arrays
Creating ArraysShape and SizeRanges of NumbersIndexing and SlicingRecap: Temperature GridPractice on your own: Online Python compiler