Quick summary
Summarize this blog with AI
A complete delivery-analysis take-home example
Suppose a fictional delivery team asks: “Which region needs attention, and what should we investigate next?” The service target is delivery within 30 minutes, inclusive. This worked case uses eight synthetic records, a complete Python script, exact output, and a short decision memo. It is a practice exercise, not a real employer's assessment or operational dataset.
What the submission needs to establish
Define the metric before calculating it, show missing outcomes explicitly, and separate the observed data from recommendations. The key lesson is that the fastest median and the highest on-time proportion can point to different regions. A small table can communicate that more clearly than a model.
Read the brief as a decision problem
Define the population and target
Assume each row represents one completed delivery in the requested reporting population. The duration is whole minutes from order acceptance to delivery. A blank duration is an unknown outcome, not zero and not proof of lateness. If the real data included still-open orders, canceled orders, or multiple events per delivery, resolve that population definition before using this calculation.
Agree on the deliverables
Submit a reproducible script, a regional summary, and a brief recommendation. The requested decision is an investigation priority, so prediction is unnecessary. If an employer requests a predictive model instead, the target, split, baseline, and evaluation would need a different design.
Prepare a small reproducible analysis
Choose tools that fit the question
The script uses Python 3's standard library; no package installation, network request, or external file is needed. Save it as delivery_case.py and run python delivery_case.py in an environment with Python 3. The CSV module reads the fixture, and statistics.median summarizes observed durations.
Inspect the data contract
North has durations 10, 15, 40, and missing; South has 20, 25, 30, and missing. Each region has four deliveries and three known durations. The parser checks column names, field counts, keys, region labels, integer conversion, and nonnegative duration. It deliberately rejects malformed records instead of silently converting them to missing values: malformed CSV raises csv.Error, and invalid fields raise ValueError. It does not establish that the source measurements are accurate.
Calculate and check the answer
Run the complete script
import csv
from io import StringIO
from statistics import median
csv_text = """delivery_id,region,minutes
1,North,10
2,North,15
3,North,40
4,North,
5,South,20
6,South,25
7,South,30
8,South,
"""
def parse_deliveries(text):
records, seen = [], set()
reader = csv.DictReader(StringIO(text), strict=True)
if reader.fieldnames != ["delivery_id", "region", "minutes"]:
raise ValueError("Unexpected columns")
for row in reader:
if None in row or any(v is None for v in row.values()):
raise ValueError("Wrong number of fields")
key = row["delivery_id"].strip()
region = row["region"].strip()
if not key or key in seen or not region:
raise ValueError("Missing key/region or duplicate delivery ID")
raw = row["minutes"].strip()
minutes = None if raw == "" else int(raw)
if minutes is not None and minutes < 0:
raise ValueError("Duration must be nonnegative")
seen.add(key)
records.append((key, region, minutes))
return records
def summarize(records):
n = len(records)
if n == 0:
raise ValueError("Cannot summarize an empty region")
observed = [m for _, _, m in records if m is not None]
missing = n - len(observed)
on_time = sum(m <= 30 for m in observed)
return {
"total": n, "known": len(observed), "missing_pct": 100 * missing / n,
"observed_pct": 100 * on_time / len(observed) if observed else None,
"lower_pct": 100 * on_time / n,
"upper_pct": 100 * (on_time + missing) / n,
"median_minutes": median(observed) if observed else None,
}
records = parse_deliveries(csv_text)
for region in sorted({region for _, region, _ in records}):
result = summarize([row for row in records if row[1] == region])
observed = result["observed_pct"]
observed_text = "NA" if observed is None else f"{observed:.2f}%"
print(
f"{region}: n={result['total']}, known={result['known']}, "
f"missing={result['missing_pct']:.2f}%, observed_SLA={observed_text}, "
f"bounds={result['lower_pct']:.2f}%..{result['upper_pct']:.2f}%, "
f"median={result['median_minutes']}"
)
Expected output:
North: n=4, known=3, missing=25.00%, observed_SLA=66.67%, bounds=50.00%..75.00%, median=15
South: n=4, known=3, missing=25.00%, observed_SLA=100.00%, bounds=75.00%..100.00%, median=25
The observed SLA proportion uses known durations as its denominator: North is 2/3, South is 3/3. Missingness uses all deliveries: 1/4 in each region. The all-delivery lower bound treats every unknown as late; the upper bound treats every unknown as on time. North is therefore 2/4 to 3/4, and South is 3/4 to 4/4. These are missing-outcome bounds for these eight rows, not confidence intervals for future performance.
Show denominators alongside results
| Region | Known on time / known | Missing / total | All-delivery bounds | Observed median |
|---|---|---|---|---|
| North | 2 / 3 (66.67%) | 1 / 4 (25%) | 50%–75% | 15 minutes |
| South | 3 / 3 (100%) | 1 / 4 (25%) | 75%–100% | 25 minutes |
North's lower median does not cancel its recorded late delivery. South's 30-minute delivery is on time because the target is inclusive. For eight observations, show the raw durations or this table; an elaborate dashboard would add little. Label the unknown values separately rather than plotting them as zero.
Write the decision memo
Use a recommendation supported by the evidence
Recommendation: Investigate the North 40-minute delivery and recover the two missing durations before changing staffing or service policy. Among observed deliveries, North meets the target on two of three records and South on three of three. Each region is missing one quarter of its durations. The all-delivery bounds overlap at 75%, so the records do not establish a strict regional difference under every possible missing outcome.
Next step: Confirm event definitions and collect a larger, comparable reporting window. Review the late delivery's timeline and whether missing timestamps share a device, route, or ingestion issue. No savings or causal effect is estimated from this fixture.
Explain what would change your recommendation
Recovering North's missing duration could put its all-delivery result at 50% or 75%; South could be 75% or 100%. Even complete records would remain only four deliveries per region. Differences in distance, order complexity, or observation windows may matter. More data should address those comparability issues, not merely increase the row count.
Review the work before submitting
Ask specific review questions
Can a reviewer identify the SLA boundary and each denominator? Can they reproduce the table without your notebook session? Does the recommendation distinguish an observed problem from an explanation? Ask for feedback on those decisions rather than asking whether the presentation looks impressive.
Test cases that change the result
Check a duration of exactly 30, a zero duration, all missing durations, duplicate IDs, and an empty region. Zero passes this numeric contract but may deserve investigation in real data. All-missing records return an unknown observed rate and bounds of 0%–100%; the script does not report perfect service. An empty region raises an error. Never fill a missing outcome with the regional median merely to improve completeness.
Package a clear final answer
Include the script, its Python version, the output table, assumptions, and memo. State that the fixture is synthetic. Keep the input and result together so the interviewer can inspect the entire chain. Use the separate time-limited take-home plan to budget the work.
Common questions
Why no machine learning? The task asks for a descriptive service assessment, and eight synthetic records cannot justify a useful prediction system.
Can the missing-data bounds prove which region is better? They describe possible results within this fixture. They neither explain the causes nor estimate population uncertainty.
Would mean imputation be harmless? No. It would turn unknown outcomes into invented delivery times and could change both the median and SLA classification.