The question
Show daily recorded steps against a supplied benchmark of 9,000 steps per day.
df Benchmark contextYour inputs
df
The benchmark is 9,000 total recorded steps per day for this dataset, not a health recommendation. Show the benchmark with a legend label.
Field meanings and units
record_id- Activity-observation identifier.
group- Comparison group.
date- Calendar date supplied as YYYY-MM-DD text unless the task states it is invalid.
steps- Recorded step count, additive across observations.
minutes- Elapsed duration in minutes; unknown is not zero.
week- Current or Previous reporting week.
record_id | group | date | steps | minutes | week |
|---|---|---|---|---|---|
| A001 | Morning | 2026-04-01 | 2500 | 20 | Previous |
| A002 | Evening | 2026-04-01 | 3070 | 27 | Previous |
| A003 | Morning | 2026-04-02 | 3640 | 34 | Previous |
| A004 | Evening | 2026-04-02 | 4210 | 41 | Previous |
| A005 | Morning | 2026-04-03 | 4780 | 48 | Previous |
View all 16 rows
record_id | group | date | steps | minutes | week |
|---|---|---|---|---|---|
| A001 | Morning | 2026-04-01 | 2500 | 20 | Previous |
| A002 | Evening | 2026-04-01 | 3070 | 27 | Previous |
| A003 | Morning | 2026-04-02 | 3640 | 34 | Previous |
| A004 | Evening | 2026-04-02 | 4210 | 41 | Previous |
| A005 | Morning | 2026-04-03 | 4780 | 48 | Previous |
| A006 | Evening | 2026-04-03 | 5350 | 55 | Previous |
| A007 | Morning | 2026-04-04 | 5920 | 21 | Previous |
| A008 | Evening | 2026-04-04 | 2640 | 28 | Previous |
| A009 | Morning | 2026-04-05 | 3210 | 35 | Previous |
| A010 | Evening | 2026-04-05 | 3780 | 42 | Previous |
| A011 | Morning | 2026-04-06 | 4350 | 49 | Previous |
| A012 | Evening | 2026-04-06 | 4920 | 56 | Previous |
| A013 | Morning | 2026-04-07 | 5490 | 22 | Previous |
| A014 | Evening | 2026-04-07 | 6060 | 29 | Previous |
| A015 | Morning | 2026-04-08 | 2780 | 36 | Current |
| A016 | Evening | 2026-04-08 | 3350 | 43 | Current |
The editable setup in Your Python creates these inputs when you run it.
Show daily recorded steps against a supplied benchmark of 9,000 steps per day.
dailySeriesfigFigureDeliverables
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.
- Daily activityOutput
dailySeries- Store summed
stepsby parsed date indaily, in time order, earliest first.
- Store summed
- FigureOutput
figFigure- Create
figconnectingdailytotals in time order, earliest first, with a horizontal benchmark at 9,000stepsidentified in a legend. - Add a meaningful title and measure labels
- Display the figure.
Identify Date and Steps 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
Does the reference value use the same units and time period as the observations?
Hint 2 — Tools
to_datetime(), groupby(), sum(), Axes.plot() and axhline()
Revisit: Parse dates · Line plot · Reference lines · Legends and palettes
Hint 3 — Approach
Calculate daily totals, show their ordered change and label a horizontal benchmark at the supplied value.
Explained solution
Add these lines below # Your work in the editor. The supplied input setup is already there.
work = df.copy()
work['date'] = pd.to_datetime(work.date, format='%Y-%m-%d')
daily = work.groupby('date').steps.sum().sort_index()
fig, ax = plt.subplots()
ax.plot(daily.index, daily.values, marker='o', label='Recorded')
ax.axhline(9000, linestyle='--', label='Benchmark: 9000 steps')
ax.legend()
ax.set(title='Daily steps and benchmark', xlabel='Date', ylabel='Steps')
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 (16 rows)
df = pd.DataFrame(
[
('A001', 'Morning', '2026-04-01', 2500, 20, 'Previous'),
('A002', 'Evening', '2026-04-01', 3070, 27, 'Previous'),
('A003', 'Morning', '2026-04-02', 3640, 34, 'Previous'),
('A004', 'Evening', '2026-04-02', 4210, 41, 'Previous'),
('A005', 'Morning', '2026-04-03', 4780, 48, 'Previous'),
('A006', 'Evening', '2026-04-03', 5350, 55, 'Previous'),
('A007', 'Morning', '2026-04-04', 5920, 21, 'Previous'),
('A008', 'Evening', '2026-04-04', 2640, 28, 'Previous'),
('A009', 'Morning', '2026-04-05', 3210, 35, 'Previous'),
('A010', 'Evening', '2026-04-05', 3780, 42, 'Previous'),
('A011', 'Morning', '2026-04-06', 4350, 49, 'Previous'),
('A012', 'Evening', '2026-04-06', 4920, 56, 'Previous'),
('A013', 'Morning', '2026-04-07', 5490, 22, 'Previous'),
('A014', 'Evening', '2026-04-07', 6060, 29, 'Previous'),
('A015', 'Morning', '2026-04-08', 2780, 36, 'Current'),
('A016', 'Evening', '2026-04-08', 3350, 43, 'Current'),
],
columns=['record_id', 'group', 'date', 'steps', 'minutes', 'week'],
)Why these steps exist
- Daily totals and the supplied benchmark share the same unit and time period.
- A labelled reference line lets a reader identify the benchmark without confusing it with another observation series.
Another valid approach
The line may use markers or no markers. The supplied reference still needs an identifiable legend entry.