All lessons

Module 8: Analyses employers ask for · Lesson 8.3 · about 15 min

Pareto and ABC analysis

Find the few products that make most of the revenue: sort, take a cumulative share, label A, B and C classes with cut, and draw the Pareto curve that stock planners and category managers use.

Key points, meanings and formulas on one page: choose "Save as PDF" in the print box.

Module 8 · about 15 minutes · uses Lessons 4.1 and 4.5. You’ll be able to rank items by contribution and split them into A, B and C classes.

Rank items by contribution, add up their shares from the top, and you see how few items make most of the result. A, B and C classes turn that into who gets attention first.

In everyday terms: a wardrobe: you wear a handful of favourite clothes most days. Those few deserve the front of the rail; the rest can go further back.

1. Cumulative share

Pythonorders.csv, products.csv

Read down the cum_% column: the top product alone is about 12 % of revenue, the top 10 together about 61 %.

2. A, B and C classes

Pythonorders.csv
  • A: the items that make the first 80 %. Never let them run out; review them weekly.
  • B: the next 15 %. Normal care.
  • C: the last 5 %, often many items. Candidates for a smaller range or ordering less often.

3. The Pareto curve

Try it: how concentrated are sales?
course shop: top products make
made-up shop: top products make
Sort the products from best to worst seller and add up their share of revenue as you go. The solid line is the course shop (real totals from orders.csv); the dashed line is a made-up shop where the i-th product sells in proportion to 1/is. At concentration 0 every product sells the same and the curve is the diagonal; the higher it goes, the more a few products dominate. The shaded band is class A, the products that make the first 80 %.

The curve rises fast and then flattens. The more it bows towards the top left, the more concentrated sales are. A straight diagonal would mean every product sells the same.

sort_values(ascending=False)
Biggest contributors first.
cumsum() / sum()
Cumulative share: how much the top items make together.
A / B / C
Up to 80 %, 80-95 %, the rest (common cut-offs; pick your own).
Shift the share by one
So the item that crosses 80 % still counts as A.
Physical meaning
The cumulative share curve rises steeply and then flattens. Its steepness says how concentrated the business is: 20 % of items making 80 % is a common pattern, not a law.

“It is always 80/20.” Concentration varies: in the course shop, 17 of 32 products make 80 %. Measure it; do not assume it.

Watch it happen, one step at a time:

Revenue by product, sorted.
productrevenue
P150
P225
P315
P46
P54
Share. Total 100: 50 %, 25 %, 15 %, 6 %, 4 %.
Cumulative. 50, 75, 90, 96, 100 %.
Classes, using the share before each item. Before P1 0 %, P2 50 %, P3 75 % → A; P4 starts at 90 % → B; P5 starts at 96 % → C.
Result.
productcum %class
P150A
P275A
P390A
P496B
P5100C

4. Your turn

Your turnorders.csv
How it works

Principle: sort the items from biggest to smallest and plot the running share of the total against the share of items. That is the Pareto curve (a Lorenz curve drawn the other way up):

L(k)=∑i=1kx(i)∑i=1nxi,x(1)≥x(2)≥…

The bigger the gap between the curve and the diagonal, the more concentrated the total. Economists turn that gap into the Gini coefficient. The 80/20 shape shows up in many places (sales, customers, defects, web pages) because a few causes often build on themselves, but always measure it; never assume it.

5. Practice

  1. ABC by units instead of revenue. Do the classes change?
  2. Do the same for customers: what share of customers makes 80 % of revenue?
  3. Why might a C product still be worth keeping?
Answers
  1. Replace revenue with qty. Cheap items move up, expensive ones down, so yes, some change class.
  2. Group by customer_id, then the same steps; count the A customers and divide by the number of customers.
  3. It may bring people in (a loss leader), complete a basket (batteries with a gadget), or have a high margin.

New words: Pareto principle, cumulative share, ABC analysis, Lorenz curve, concentration.

  • Sort by contribution, then cumsum ÷ sum.
  • Classify on the share before each item, so the crossing item is A.
  • Cut-offs like 80/95 are choices; state them.
  • Measure concentration; do not assume 80/20.

Check yourself

1What does the 80/20 rule say, roughly?
2Which steps give each product its cumulative share of revenue?
3Why use the share BEFORE a product when labelling A items?

Sources

  • Juran, J. M. (1951), Quality Control Handbook, McGraw-Hill (the Pareto principle)
  • McKinney, W. (2022), Python for Data Analysis, 3rd edition, O'Reilly (open access) https://wesmckinney.com/book/

Your ticks stay in this browser. Save them as a file on the course home.

Updated 2026-11-22. All datasets are made up. Python runs in your browser (the first run downloads it once, about 20 MB); nothing you type is sent anywhere.