Sub topic 1
Start with Questions, Not Code
An exploratory data analysis (EDA) goes better when you decide what you want to learn before you write any analysis code. This chapter shows how to turn a vague request into questions you can answer from the data, and how to record them at the top of the notebook.
Prerequisites
This chapter assumes you know:
- Basic Python (functions, imports, f-strings).
- pandas DataFrames and basic indexing.
- How to run cells in Jupyter or a similar notebook environment.
- Introductory statistics (mean, median, distribution, correlation).
No code is needed to follow this chapter. The later chapters apply these ideas to an orders dataset.
Why questions come first
Without a question, EDA turns into a pile of ad-hoc cells. You plot whatever columns come to mind, find a pattern, and cannot say why it matters. Questions give each cell a purpose. They also tell you when to stop.
A good EDA question has three traits:
- It can be answered with the data you have.
- It names a variable, a group, or a time span.
- Its answer changes what someone does next.
From a request to questions
Requests usually arrive vague. "Look at our orders" is a request, not a question. Break it down in three steps:
- Write down the decision the analysis supports, such as which regions need attention.
- List the questions whose answers would inform that decision.
- Note which columns each question needs.
The table shows how this works for an orders dataset.
| Vague request | Question the data can answer | Columns needed |
|---|---|---|
| Look at our orders | How are order amounts distributed? | `amount` |
| Which regions matter? | Do order amounts differ by region? | `amount`, `region` |
| Is the data usable? | How many rows have missing or negative amounts? | `amount` |
The third row is a data quality question. Every EDA has some, because you cannot trust later findings until you have checked the data.
Writing the goals into the notebook
Put the goals in a markdown cell at the top of the notebook. Keep the cell short. Here is an example.
# Order amounts: exploratory analysis
## Goal
Understand how order amounts vary so the sales team can decide which regions to review.
## Questions
1. How are order amounts distributed?
2. Do order amounts differ by region?
3. How many rows have missing or negative amounts?
## Out of scope
Forecasting and customer-level analysis.The "Out of scope" list matters. It stops the notebook from growing every time you notice something interesting.
Questions change, and that is fine
Exploration often raises new questions. Add them to the list as you go, and mark the original ones as answered, changed, or dropped. Later chapters show how to record each finding next to its evidence. For now, treat the question list as a living part of the notebook.
Common errors
- Questions too broad. "What is in the data?" cannot be answered. Name a column or a group.
- Questions written after the plots. You then fit the question to the result you found, which makes patterns look more meaningful than they are.
- No stopping point. If nothing says what "done" means, the notebook never ends. Tie it to the decision from step 1.
Exercise
A manager asks you to "explore the customer data". Write two questions that follow this chapter's advice. For each, name the columns you would need. Then say what the first markdown cell of the notebook should contain.
Show answer
Example questions: "Do customers who signed up in the last 90 days place fewer orders than older customers?" (columns: signup_date, order_count) and "What share of customers have no email address?" (column: email). The first markdown cell should state the goal and the decision it supports, list the numbered questions, and give an out-of-scope list.