twoHelixestwoHelixes Start free

Datasets / Sales orders

Refund rate by product category

A rate, computed from the flag rather than counted twice: the mean of a boolean is the share that are true.

Question what share of orders get refunded, by category?
Refund rate by category01234SupportServicesSoftwareHardwareTrainingRefund Rate
Sales orders — 5 rows charted from 11,316, drawn as a hbar
How it decided
Finding the data111 ms

Sales orders: 11,316 rows, 10 columns. category and the refunded flag. Amounts are irrelevant to a rate.

Shaping the data26 ms

11,316 rows in, 5 out across 2 columns. A rate, computed from the flag rather than counted twice: the mean of a boolean is the share that are true.

Choosing the chart4 ms

hbar. Category names are long, so the bars run horizontally and the labels stay readable rather than rotating.

Applying defaults1 ms

Palette, spacing, axis titles and legend placement applied. 0 issues found.

The transformation

This is the code, not a description of it — the chart above was drawn from what it returns, and the notebook download runs the same lines against the same file.

result = df.groupby("category", as_index=False)["refunded"].mean()
result["refund_rate"] = result["refunded"] * 100
result = result[["category", "refund_rate"]].sort_values("refund_rate", ascending=False)

What it charted

5 rows out of 11,316, 2 columns. First 5 shown.

categoryrefund_rate
Support3.8613
Services3.5011
Software3.2459
Hardware2.4793
Training2.4047