Practical Data Analysis Course / Chapter 1 — What to Decide Before You Analyze (lessons 1–4) / Lesson 1
Break a Question into Metric, Target, and Period
Time needed: about 5 min (estimate)
Reading settings
These settings are remembered on this device only.
You can try the opening of this lesson without an account.
How this course works
This course is a practical introduction to data analysis for people who've already learned Python and SQL.
It doesn't build models — instead it walks through framing a question → pulling data with SQL → cleaning it up → presenting it → standard analyses → communicating results.
The material stays fixed on a single fictional e-commerce shop's data, reused across all 30 lessons.
Sample data (used throughout)
The sample code's lib/dataset.py fixes the random seed, so it produces the same data every time you build it.
Figures that appear in the text, like completed orders totaling ¥1,062,050, stay the same every run.
Verified with Python 3.14.2, SQLite 3.51.0, pandas 3.0.5, matplotlib 3.11.1, and pytest 9.1.1.
Terminal (setting up the sample code)
"How's revenue doing?" can't be measured as-is
"How's revenue doing?" is a common question, but you can't act on it as stated.
That's because what to measure (the metric), what data to measure it against (the target), and what time range (the period) haven't been decided.
Once these three are in place, the question becomes something you can measure — and translate directly into SQL.
Three parts of breaking down a question
Checking measurability with a function
A function that checks whether the three parts are all in place, along with an example that turns a vague question into a measurable one.
It uses all() to check that metric, target, and period are all filled in.
It only needs the standard library, so you can run it right where you are.
Try removing a key and see how the result changes.
Tab indents. To leave the editor, press Esc, then Tab.
Create a free account to keep reading
With an account you can read the rest of this lesson, take the quiz, and read every free lesson in this course. Lessons you answer correctly are recorded as complete.
Report a problem with this lesson
Log in to send a report.