The question
Show how delivery durations are distributed, excluding measurements that cannot be interpreted.
df Duration distributionYour inputs
df
These records describe completed deliveries. Durations are minutes; unknown text and blank values are not measurements.
Field meanings and units
delivery_id- Delivery identifier.
depot- Depot responsible for the delivery.
status- Recorded delivery state.
minutes- Elapsed duration in minutes; unknown is not zero.
weight_kg- Weight in kilograms.
date- Calendar date supplied as YYYY-MM-DD text unless the task states it is invalid.
delivery_id | depot | status | minutes | weight_kg | date |
|---|---|---|---|---|---|
| D001 | East | Delivered | 32 | 1.2 | 2026-04-01 |
| D002 | West | Delivered | 48 | 1.9 | 2026-04-01 |
| D003 | North | Delivered | 25 | 2.6 | 2026-04-02 |
| D004 | East | Delivered | unknown | 3.3 | 2026-04-02 |
| D005 | West | Delivered | 45 | 4 | 2026-04-03 |
View all 20 rows
delivery_id | depot | status | minutes | weight_kg | date |
|---|---|---|---|---|---|
| D001 | East | Delivered | 32 | 1.2 | 2026-04-01 |
| D002 | West | Delivered | 48 | 1.9 | 2026-04-01 |
| D003 | North | Delivered | 25 | 2.6 | 2026-04-02 |
| D004 | East | Delivered | unknown | 3.3 | 2026-04-02 |
| D005 | West | Delivered | 45 | 4 | 2026-04-03 |
| D006 | North | Delivered | 37 | 1.2 | 2026-04-03 |
| D007 | East | Delivered | 72 | 1.9 | 2026-04-04 |
| D008 | West | Delivered | 29 | 2.6 | 2026-04-04 |
| D009 | North | Delivered | 33 | 3.3 | 2026-04-05 |
| D010 | East | Delivered | None | 4 | 2026-04-05 |
| D011 | West | Delivered | 26 | 1.2 | 2026-04-06 |
| D012 | North | Delivered | 62 | 1.9 | 2026-04-06 |
| D013 | East | Delivered | 46 | 2.6 | 2026-04-07 |
| D014 | West | Delivered | 38 | 3.3 | 2026-04-07 |
| D015 | North | Delivered | 73 | 4 | 2026-04-08 |
| D016 | East | Delivered | 30 | 1.2 | 2026-04-08 |
| D017 | West | Delivered | 34 | 1.9 | 2026-04-09 |
| D018 | North | Delivered | 50 | 2.6 | 2026-04-09 |
| D019 | East | Delivered | 27 | 3.3 | 2026-04-10 |
| D020 | West | Delivered | 63 | 4 | 2026-04-10 |
The editable setup in Your Python creates these inputs when you run it.
Show how delivery durations are distributed, excluding measurements that cannot be interpreted.
durationsSeriesfigFigureDeliverables
Make the outputs listed below. Use each name exactly as shown. Then choose Check answer.
Python name key
Teal outlines name table columns. Violet left rules name Python objects. Dotted rules mark syntax, functions and parameters. Use each name exactly as shown.
Words in this task
- numeric
- a number, rather than text
- missing
- no value was supplied
- eligible
- rows that meet this task’s stated conditions
- Valid durationsOutput
durationsSeries- Store parsed, non-missing
minutesindurations, keeping source order. - Do not fill unknown
durationswith zero.
- Store parsed, non-missing
- FigureOutput
figFigure- Create
figshowing delivery frequencies across at least two contiguous numeric duration intervals. - Include every eligible duration and start the frequency axis at zero.
- Add a meaningful title and measure labels
- Display the figure.
Identify Minutes and Deliveries on the appropriate axes; extra wording is welcome.
- Create
Data policy Keep all supplied source tables unchanged. Work on separate outputs.
Help Hints & explained solution
Choose the amount of help you need. Opening one hint does not reveal the others.
Hint 1 — Think
Would a zero-filled unknown become a misleading instant delivery?
Hint 2 — Tools
to_numeric(), dropna() and Axes.hist()
Revisit: Convert numeric text · Drop missing rows · Histogram · Finish a chart properly
Hint 3 — Approach
Parse durations, retain observed values and show their frequency across contiguous numeric intervals.
Explained solution
Add these lines below # Your work in the editor. The supplied input setup is already there.
durations = pd.to_numeric(df.minutes, errors='coerce').dropna()
fig, ax = plt.subplots()
ax.hist(durations, bins=5)
ax.set(title='Delivery duration distribution', xlabel='Minutes', ylabel='Deliveries')
fig.tight_layout()
plt.show()View supplied setup
This code is already at the top of the editor.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Supplied input: df (20 rows)
df = pd.DataFrame(
[
('D001', 'East', 'Delivered', '32', 1.2, '2026-04-01'),
('D002', 'West', 'Delivered', '48', 1.9, '2026-04-01'),
('D003', 'North', 'Delivered', '25', 2.6, '2026-04-02'),
('D004', 'East', 'Delivered', 'unknown', 3.3, '2026-04-02'),
('D005', 'West', 'Delivered', '45', 4, '2026-04-03'),
('D006', 'North', 'Delivered', '37', 1.2, '2026-04-03'),
('D007', 'East', 'Delivered', '72', 1.9, '2026-04-04'),
('D008', 'West', 'Delivered', '29', 2.6, '2026-04-04'),
('D009', 'North', 'Delivered', '33', 3.3, '2026-04-05'),
('D010', 'East', 'Delivered', None, 4, '2026-04-05'),
('D011', 'West', 'Delivered', '26', 1.2, '2026-04-06'),
('D012', 'North', 'Delivered', '62', 1.9, '2026-04-06'),
('D013', 'East', 'Delivered', '46', 2.6, '2026-04-07'),
('D014', 'West', 'Delivered', '38', 3.3, '2026-04-07'),
('D015', 'North', 'Delivered', '73', 4, '2026-04-08'),
('D016', 'East', 'Delivered', '30', 1.2, '2026-04-08'),
('D017', 'West', 'Delivered', '34', 1.9, '2026-04-09'),
('D018', 'North', 'Delivered', '50', 2.6, '2026-04-09'),
('D019', 'East', 'Delivered', '27', 3.3, '2026-04-10'),
('D020', 'West', 'Delivered', '63', 4, '2026-04-10'),
],
columns=['delivery_id', 'depot', 'status', 'minutes', 'weight_kg', 'date'],
)Why these steps exist
- Invalid durations are unknown observations, not instant deliveries.
- Bins collect counts across contiguous intervals; different sensible bin counts show the same underlying observations.
Another valid approach
Different sensible bin counts are accepted. Every eligible duration must be included and bar heights must represent frequencies.