Field note · June 22, 2024
What discount_pct actually contains in retail-orders
7,000 rows, 42 distinct values, and the one fact about discount_pct that changes how you query it.
Working through retail-orders again. discount_pct is the column people trip over, so here is what it actually looks like.
7,000 rows, no nulls, 42 distinct values. Discount applied, 0–0.45.
The five-number version: min 0.00, p10 0.00, median 0.00, p90 0.28, max 0.45. The mean is 0.10.
The p10 to p90 band — 0.00 to 0.28 — is where ordinary rows live, and it is the pair worth quoting when somebody asks what to expect. Min and max describe the two strangest rows in the table and nothing else; they are useful for spotting impossible values and misleading for everything else.
select
count(*) as rows,
count(discount_pct) as present,
count(*) - count(discount_pct) as nulls,
count(distinct discount_pct) as distinct_values
from retail_orders;3,588 rows are exactly zero — 51.3% of the column. Decide what a zero means here before you average anything, because "did not happen" and "measured zero" do not belong in the same denominator.
Where this bites: the two populations move independently. A drop in the overall average could be fewer non-zero rows or smaller non-zero values, and one number cannot tell you which — so the reporting version is usually a rate and a size rather than a mean.
The grain is one row per order line, which is the context every one of those numbers depends on. None of them survive a change of grain, which is why "profile the column" and "profile the table" are the same job. Full schema, and the CSV, on the dataset page.