Sub topic 2
What a Pareto chart contains
This section assumes you know basic percentages, can add a running total, and have used pandas Series. It covers the three parts of a Pareto chart, builds one in Python, and shows how to read it.
The three parts of a Pareto chart
A Pareto chart has three parts:
- Sorted bars: one bar per category, tallest on the left. Each bar height is a count or a cost.
- A cumulative line: a running total of the percentages, plotted against a right-hand axis from 0 to 100 percent.
- An 80 percent reference: a horizontal line at 80 percent. It marks where the "vital few" end.
Building a Pareto chart in Python
The code below sorts the defect counts, keeps the "Other" bucket last, and computes the cumulative percentage.
import pandas as pd
defects = pd.Series({
"Scratches": 42,
"Misalignment": 27,
"Wrong label": 11,
"Cracks": 8,
"Discoloration": 5,
"Other": 7,
})
main = defects.drop("Other").sort_values(ascending=False)
data = pd.concat([main, defects[["Other"]]])
cum_pct = data.cumsum() / data.sum() * 100
table = pd.DataFrame({"count": data, "cumulative_pct": cum_pct.round(1)})
print(table)The table below shows the result for this data.
| Category | Count | Cumulative % |
|---|---|---|
| Scratches | 42 | 42.0 |
| Misalignment | 27 | 69.0 |
| Wrong label | 11 | 80.0 |
| Cracks | 8 | 88.0 |
| Discoloration | 5 | 93.0 |
| Other | 7 | 100.0 |
Reading the chart to find the vital few
Find the first bar where the cumulative line reaches 80 percent. Every bar up to and including that one is the vital few. Here, Scratches, Misalignment, and Wrong label together make up 80 percent of defects. The remaining three categories make up the other 20 percent.
Exercise
Using the table above, how many categories are in the vital few, and what share of defects do they cover?
Show answer
Three categories (Scratches, Misalignment, and Wrong label) cover 80 percent of the 100 defects.