Sales Report
Part of the Data and Plots section of Coddy's Machine Learning journey. Lesson 57 of 60.
A furniture shop logged its March orders in sales.csv, one row per order: date, region, product, units, price and cost (both per unit).
Each regional manager wants one chart: profit per product, top earner first. Here is East's:
An order's profit is what the shop keeps: the price minus the cost, times the units.
Challenge
HardThe program reads a region.
- Keep that region's orders and add a
profitcolumn. - Total the profit per product, largest first.
- Print the number of orders, then the top product with its total and its share of the region's profit, as a percent rounded to 1 decimal.
- Draw the totals as bars with the
fig, axform, titledProfit inand the region, labelledProductandProfit.
For East, the whole output is below: your two lines, then Coddy's description of your chart.
Orders in East: 13
Most profit in East: Desk (414.0), 23.4% of the region
Charts drawn: 1
Title: Profit in East
X label: Product
Y label: Profit
Bars: 5
Categories: Desk, Chair, Lamp, Shelf, Rug
Heights: [414, 408, 363, 337.5, 250]Try it yourself
import pandas as pd
import matplotlib.pyplot as plt
region = input()
# Write your code below
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Data and Plots
2NumPy Arrays
Creating ArraysShape and SizeRanges of NumbersIndexing and SlicingRecap: Temperature GridPractice on your own: Online Python compiler