…
…
Statistics and Data Analysis Fundamentals · Lesson 1 / 44 · Asking questions with data
PreviewIn this lesson you will
You can read the explanation without an account. The exercises and quiz at the end of the lesson are for members.
On a Monday morning, the manager of the online store Bazaar sends the team a one-sentence message: "Sales are down, why?" You are the store's data analyst, and you will answer this question step by step, from the first lesson to the final report. Today's job is not to open the data yet, but to make the question measurable.
By the end of this lesson, you will have turned the manager's one-sentence message into the table below. For now, just look at it. At the end of the lesson, you will write the same thing yourself:
| Sub-question | Metric | Period and comparison | Breakdown |
|---|---|---|---|
| How much did the monthly order count fall? | Order count | May–June monthly average, compared with the January–April monthly average | none |
| Does the drop come from fewer orders or smaller carts? | Revenue, average order value | Same | none |
| On which device is the drop bigger? | Order count | Same | Device |
In this lesson you will:
Data analysis means answering a question with data and turning that answer into a decision. The last word matters most: the goal is not to produce numbers, it is to make a better decision. The manager's message "sales are down" is a question, but it is not a question you can answer yet. An analyst makes it measurable, finds the right data, cleans it, explores it, interprets it, and finally turns it into a recommendation the manager can understand. Statistics is the language of this work. It teaches you how to measure uncertainty, how to tell chance from a real effect, and how to speak carefully about a wider picture from a small piece of data.
When people get the message, many of them first open all the sales data and start drawing charts. This looks fast and productive, but it often leads to the wrong place. Think first.
The manager says "sales are down." What is the analyst's first job?
Data analysis is not a single step. It is a cycle that repeats. The table shows the six steps and what each one means at Bazaar:
| Step | Question | At Bazaar |
|---|---|---|
| 1. Question | What exactly do we want to find out? | Which sales measure fell, in which period, compared with what? |
| 2. Data | Which data can answer this question? | Orders, customers, products, site sessions |
| 3. Cleaning | Can we trust the data? | Duplicate records, missing and wrong values |
| 4. Exploration | What do we see in the data? | Summaries and charts by month, device, and category |
| 5. Inference | Is the difference we see real, or chance? | Confidence intervals, hypothesis tests, A/B test |
| 6. Decision and story | What should we do? | A short report with the findings and a recommendation |
Put the steps of a data analysis in the correct order.
Click the lines in order; to undo one you placed wrong, click it in the list below.
Shuffled lines
Your order
These steps do not always go in a straight line. While exploring, you may notice that part of the data is wrong and go back to cleaning. You may look at a chart and rewrite the question. Good analysts do not count these returns as mistakes. They see them as a normal part of the work. The units of this course follow the same cycle. First we build the question. Then we get to know the data with pandas. Then we explore distributions, then we clean the data, and finally we reach inference, relationships, and decisions. Exploration comes before cleaning for a simple reason: to recognize dirty data, you first need to see what a clean distribution looks like.
A short history. This way of thinking is not new. In 1662, a shopkeeper in London counted the deaths in church records week after week and worked out how epidemics spread and faded. In the 1850s, a nurse used a chart to show that most soldier deaths in war came from disease, not from wounds, and hospitals changed how they worked. Today the same work is done with online store orders instead of death records.
Bazaar has data for six months, from January to June 2026. For a first look, let's print the monthly order counts. All the code in this lesson uses the lists, loops, and functions you know from the Python course. We will move to pandas in lesson 4.
months = ["January", "February", "March", "April", "May", "June"] monthly = [154, 177, 176, 162, 112, 104] for month, n in zip(months, monthly): print(month, n)
OutputJanuary 154
February 177
March 176
April 162
May 112
June 104Even this simple list says something. Between January and April, 150 to 180 orders came in each month. In May and June, the count fell to about 110. The drop looks real, and it started in May. But the answer to "why?" is not in these six numbers.
The sentence "sales are down" carries three uncertainties. Which measure fell: order count or revenue? In which period did it fall? Compared with what: last month, last year, or the first months of the year? Until these uncertainties are removed, two analysts can reach opposite results from the same data, and both think they are right.
An analysis question becomes clear with four parts:
| Part | What it says | Bazaar example |
|---|---|---|
| Metric | What do we count or measure? | Monthly order count |
| Period | Which time range do we look at? | May–June 2026 |
| Comparison | Compared with what did it rise or fall? | Compared with the January–April monthly average |
| Breakdown | In which part? | Device (mobile, desktop) |
A question with all four parts reads like this: "How much did the monthly order count in May–June 2026 change compared with the January–April monthly average, and which device does the change come from?" It is a long sentence, but now anyone who asks it will do the same calculation.
The metric must be defined exactly. At Bazaar, does an order that was returned or canceled count as a sale? We will decide this in lesson 10 by looking at the data. For now, one rule is enough: whichever definition you choose, write it in the report.
What job does each part of this question do? "How much did the monthly order count in May–June 2026 change compared with the January–April monthly average, and which device does the change come from?"
For each row, pick its match from the list, then check.
For the comparison, we need a calculation: percent change. You may remember the formula from school: percent change = (new − old) / old × 100. The denominator is always the old value, because we ask "how much did it change compared with the old value?" At Bazaar, let's compare the monthly average of the four months before the drop with the monthly average of the two months after it:
monthly = [154, 177, 176, 162, 112, 104] before = sum(monthly[:4]) / 4 after = sum(monthly[4:]) / 2 change = (after - before) / before * 100 print("January–April average:", before) print("May–June average:", after) print("Change (%):", round(change, 1))
OutputJanuary–April average: 167.25
May–June average: 108.0
Change (%): -35.4The monthly average order count fell by about one third. This is not the answer. It is the start of the question. Change the comparison point yourself and see how the result moves.
Try it now· not graded; doesn't affect progress
When the comparison point is a single month, the result depends on whether that month was good or bad. The average of four months is a firmer base.
What the manager calls "sales" can be at least three separate metrics: order count, revenue (the total sales amount), and average order value (revenue ÷ order count, the average amount per order). The three are connected: revenue = order count × average order value. When revenue falls, the first question is: are fewer people buying, or are the buyers spending less? The fixes for these two cases are different.
months = ["January", "February", "March", "April", "May", "June"] orders = [154, 177, 176, 162, 112, 104] revenue = [11395, 15674, 13257, 11809, 8664, 6044] for month, n, r in zip(months, orders, revenue): print(month, n, r, round(r / n))
OutputJanuary 154 11395 74
February 177 15674 89
March 176 13257 75
April 162 11809 73
May 112 8664 77
June 104 6044 58Each row has the month, the order count, the revenue ($, rounded to whole dollars), and the average order value ($). There is an interesting detail: in May the order count fell sharply, but the average order value is higher than in April. See below what happens when you look at the same drop with three metrics.
Change the metric: how many different sizes does the sentence "sales fell" describe?
Pick a value; predict the output first, then look.
1metric = "orders"2data = {3 "orders": [154, 177, 176, 162, 112, 104],4 "revenue": [11395, 15674, 13257, 11809, 8664, 6044],5 "basket": [74, 89, 75, 73, 77, 58],6}7x = data[metric]8before = sum(x[:4]) / 49after = sum(x[4:]) / 210change = round((after - before) / before * 100, 1)11print(metric, round(before), "→", round(after), "| change %", change)
orders 167 → 108 | change % -35.4
Faded lines didn't run with this value. The same "sales fell" sentence describes three different sizes depending on the metric: orders fell 35.4%, revenue fell 43.6%, and average order value fell 13.2%. Most of the drop in revenue comes from the order count, so the report always names the metric.
In May the average order value is higher than in April ($77 compared with $73). Which sentence follows from the table?
There is one more trap: the length of the periods. January–April is four months, and May–June is two months. If you compare the total of four months with the total of two months, the second period looks half as big even if nothing changed. So periods of different lengths are compared with monthly averages, not totals. All the calculations above follow this rule.
A drop in the total is often not equal everywhere. It is concentrated in one part. A breakdown splits the total into parts and looks at each part separately. Bazaar orders come from two devices: mobile and desktop. Let's calculate the monthly counts for each one:
mobile = [89, 104, 117, 97, 56, 53] desktop = [65, 73, 59, 65, 56, 51] for name, x in [("mobile", mobile), ("desktop", desktop)]: before = sum(x[:4]) / 4 after = sum(x[4:]) / 2 print(name, before, after, round((after - before) / before * 100, 1))
Outputmobile 101.75 54.5 -46.4
desktop 65.5 53.5 -18.3The drop is on both devices, but it is about two and a half times as sharp on mobile. This does not tell you the cause. It only tells you where to look. What changed on mobile is the subject of the next lessons.
Analyses fall into four types by the question they answer. Knowing which type of question you are asking also tells you which tool you need.
| Type | Question it answers | Bazaar example |
|---|---|---|
| Descriptive | What happened? | How many orders came in May? |
| Diagnostic | Why or where did it happen? | Which device does the drop come from? |
| Inferential | Is the difference we see only chance? | Did the new checkout page really reduce sales? |
| Predictive | What will happen? | At this pace, how many orders do we expect in July? |
Most of the calculations so far were descriptive. The device breakdown was a diagnostic step. This course focuses on the first three types. Prediction appears briefly in the regression lessons.
Which type of analysis does each question belong to?
For each row, pick its match from the list, then check.
The biggest danger in data analysis is to know the answer in advance and look for it in the data. The manager may say, "It is definitely because of the ads." This idea may not be wrong, but for now it is a hypothesis: an idea waiting to be tested. The analyst's job is to note the idea, list the other things that changed on the same dates (a new checkout page, a shipping fee, a competitor's discount), and test all of them with the data. An analyst who only looks for charts that confirm the manager's idea cannot see the evidence against it.
The manager writes: "The drop is definitely because the ad campaign ended. Let's turn the ads back on tomorrow." What do you do?
Pick an option and see what happens. There are no points; you can try the other options too.
This way of thinking is not only for stores. When the manager of a university library says, "Fewer people came to the library in November," you ask the same four parts: the metric is the daily average number of entries, the period is November 2025, but compared with what? Compared with the previous month, you see a big drop. But October is a busy month before exams. When you compare November with last year's November, the picture changes. You will see the calculation in Example 5 below. The comparison point changes the result, so it is a part of the question and not a detail added later.
Finally, let's name a common mistake: producing charts and tables before the question is clear. Drawing a chart is easy and fast, and because it is easy, skipping the question is tempting. But if you have twenty nice charts and none of them answers the manager's question, the work is wasted. The four-part question you built in this lesson will be the compass for every lesson after this one.
The daily average number of entries at a university library was 420 in October 2025, 310 in November 2025, and 300 in November 2024.
october_2025 = 420 november_2025 = 310 november_2024 = 300 vs_month = (november_2025 - october_2025) / october_2025 * 100 vs_year = (november_2025 - november_2024) / november_2024 * 100 print("Compared with the previous month %:", round(vs_month, 1)) print("Compared with the same month last year %:", round(vs_year, 1))
OutputCompared with the previous month %: -26.2
Compared with the same month last year %: 3.3October is a busy month before exams. When you compare November with last year's November, there is no drop, and there is even a small increase.
Let's compare the same revenue data first with period totals, then with monthly averages.
revenue = [11395, 15674, 13257, 11809, 8664, 6044] total_before = sum(revenue[:4]) total_after = sum(revenue[4:]) wrong = (total_after - total_before) / total_before * 100 print("With totals %:", round(wrong, 1)) before = total_before / 4 after = total_after / 2 print("With monthly averages %:", round((after - before) / before * 100, 1))
OutputWith totals %: -71.8
With monthly averages %: -43.6Totals compare four months with two months, so they make the drop look almost twice as big. The correct comparison uses monthly averages.
Opening the data and starting to produce random charts and tables right away, or sending the manager a line like this:
OutputSales fell 35%.Which sales, which period, compared with what? An analysis done before the question is clear answers a question nobody asked, very nicely, and the manager still asks, "But why did it fall?" The better way: first write the metric, the period, the comparison, and the breakdown, and only then return to the data. The line in the report carries these parts too:
OutputThe May–June monthly average order count fell 35.4% compared with the January–April monthly average.Next lesson: We have built the question. Now it is time to look at the data: what does a row in a table describe, and what types are the columns?
Exercises and quiz are for members
This lesson has 7 coding exercises and a 10-question quiz. Sign up free to solve them, save your progress and move on to the next lesson.