…
…
Statistics and Data Analysis Fundamentals · Lesson 44 / 44 · Capstone
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.
The board meets tomorrow, and there is one question on the agenda: why did sales fall, and what should we do? In earlier lessons you found the pieces of this answer one at a time. Now you will put them together in one analysis and write the one-page report that goes to the board.
This is a capstone lesson, so there are no new tools. Over the course you solved Bazaar's hidden story piece by piece. In lesson 10 you wrote a first answer to "What changed in May?". In lesson 22 you cleaned the raw file and wrote three hypothesis cards. In lesson 35 you learned to pick a method to fit the question. In the lessons after that you met association, confounders, the funnel, time, experiments, and the most common mistakes. Each lesson gave you one piece. The board does not want the pieces. It wants the answer.
You will hand in two things in this lesson. The first is a one-page executive summary for Bazaar. Its title states the result. Its first paragraph is enough on its own for a decision. Its evidence comes with numbers and intervals. Its recommendations name an owner and a measure. It does not hide its limitations. The second is a transfer: you will repeat the same chain on data you have never seen, a satisfaction survey from a university dining hall, in four steps. Memorizing Bazaar is not enough. You have learned the chain when you can build it for a different question too.
In this lesson you will:
An end-to-end analysis applies the steps you learned in this course in a fixed order. Each step depends on the result of the one before it. If you clean data without a clear definition of the metric, you do not know what you are cleaning. If you explore uncleaned data, you take amounts written 10 times too large for "record orders". If you put a difference you found in exploration into the report without testing it, you present a result of chance as a finding. If one link in the chain is weak, the whole report is only as strong as that link.
Put the steps of an end-to-end analysis in the right order.
Click the lines in order; to undo one you placed wrong, click it in the list below.
Shuffled lines
Your order
At the end of each step you will write one sentence for the report. In the exercises these sentences are stored in variables such as sentence_3 and sentence_4, and in the last step the executive summary is built from them. This habit keeps you from staring at an empty page at the very end and wondering what to write. The report builds itself as the analysis moves forward.
The board's question has two parts: "why did it fall" and "what should we do". Before both there is a third question: what fell? Is "sales" the number of orders, revenue, or the average order value? Is it completed orders only, or all orders including returns and cancellations? In lesson 10 you counted completed orders only, and in lesson 22 you counted all orders. Both can be defended. What matters is to make the choice at the start and write it in the report. In this lesson we count all orders (completed, returned, canceled), as in lesson 22. The question is about how customers behave when they place orders, and a customer who cancels has still decided to order.
Next come the periods. January to April are the four months when the ads were running. May to June are the two months when the ads stopped and the new mobile checkout page opened. Because the periods have different lengths, we compare monthly averages, not totals. In the degistir block of lesson 22 you saw that totals show a 68 percent drop, while the monthly average shows 35.4 percent.
The choice of periods has one more trap. In the previous lesson you corrected the sentence "Orders collapsed by 41 percent" in a draft report. That sentence compared the best month, February (177 orders), with the worst month, June (104). Picking the start and end point to fit the story you want is cherry-picking. The comparison periods are chosen before the analysis, with a reason, and they do not change because the result is disliked.
A board member who reads the draft report says: "Instead of the January to April average, compare February with June. A 41 percent drop is more striking, and the board will understand how serious this is." What do you do?
Pick an option and see what happens. There are no points; you can try the other options too.
The definitions are ready, so now we turn to the raw file. In lesson 22 you cleaned the 902-row export step by step. Here we summarize the same work in a five-line log: duplicates and test orders, spelling differences, prices stored as strings, three different date formats, and amounts written 10 times too large. Only the first and last lines are new: before cleaning we measure the revenue of the raw file, and at the end we print its difference from the clean revenue. This difference is the price of the belief that "analysis without cleaning is roughly right".
Example 1 (case): A five-line cleaning log, and raw versus clean revenue
import pandas as pd h = pd.read_csv("orders_raw.csv") raw_revenue = h["amount"].sum() log = [] # 1) Duplicates and test orders before = len(h) h = h.drop_duplicates() h = h[h["customer_id"] != "TEST"] log.append(("duplicates and test (rows)", before, len(h))) # 2) Spelling: device and status (distinct spellings, both columns together) before = h["device"].nunique() + h["status"].nunique() for column, fix in [("device", {"desk top": "desktop"}), ("status", {"complete": "completed"})]: h[column] = h[column].str.replace("", "").str.strip().str.lower().replace(fix) log.append(("spelling (device + status)", before, h["device"].nunique() + h["status"].nunique())) # 3) Price: from string to number def convert_price(text): text = text.replace(" USD", "") return float(text.replace(",", )) before = pd.to_numeric(h[], errors=).isna().() h[] = h[].map(convert_price) log.((, before, h[].isna().())) d = pd.to_datetime(h[], format=, errors=) before = d.isna().() d = d.fillna(pd.to_datetime(h[], format=, errors=)) h[] = d.fillna(pd.to_datetime(h[], format=, errors=)) log.((, before, h[].isna().())) h[] = h[].fillna((h[] / (h[] * (1 - h[]))).()).() expected = h[] * h[] * (1 - h[]) ten_x = (h[] / expected).(1) == 10 before = ten_x.() h.loc[ten_x, ] = (h.loc[ten_x, ] / 10).(2) log.((, before, ((h[] / expected).(1) == 10).())) (pd.DataFrame(log, columns=[, , ]).to_string(index=)) clean_revenue = h[].() ((h), (clean_revenue, 2), (raw_revenue - clean_revenue, 2))
Output step before after
duplicates and test (rows) 902 885
spelling (device + status) 15 5
price (not a number) 111 0
date (unreadable) 172 0
amount (10 times) 12 0
885 66843.57 10192.48The five lines of the log give you the recipe for the cleaning: 17 rows were removed (14 duplicates, 3 test orders), the 15 different spellings in two columns shrank to 5 (2 in device, 3 in status), 111 string prices and 172 dates in other formats were converted, and 12 amounts had been written 10 times too large. The last line is the check: 885 rows and $66,843.57, the same numbers you matched to the cent with the clean copy (orders.csv) in lesson 22.
The real lesson is in the last number: the raw file's revenue is $10,192.48 higher than the clean revenue. That is about four weeks of Bazaar's revenue. If you had written the report from the raw file, you would also have shown the drop differently: some of the 10-times amounts were in May and June, and the duplicate rows were not spread evenly across the periods. Cleaning is not a polish that slightly improves a "roughly right" result. It is a step that can change the result itself. The sentence for the report comes from here too: "The analysis was done on 885 orders cleaned from the 902-row raw export; the cleaning log is attached."
In the next examples we read the clean copy (orders.csv) to keep the code short. As you just checked, it is identical to yours.
The first exploration question is "by how much did it fall?", and the answer is not a single number. Revenue = number of orders × average order value (AOV), the average amount per order. You saw this breakdown in lesson 40: if revenue fell, then either fewer orders arrived, or orders became smaller, or both. Which one it is changes the recommendation. Fewer orders is about bringing in or keeping customers. A smaller AOV is about price, product mix, or promotions.
Example 2 (case): Orders, revenue, and average order value
import pandas as pd o = pd.read_csv("orders.csv") o["date"] = pd.to_datetime(o["date"]) o["period"] = "Jan-Apr" o.loc[o["date"] >= "2026-05-01", "period"] = "May-Jun" months = pd.Series({"Jan-Apr": 4, "May-Jun": 2}) g = o.groupby("period").agg(orders=("order_id", "count"), revenue=("amount", "sum")).loc[["Jan-Apr", "May-Jun"]] monthly = g.div(months, axis=0) monthly["aov"] = g["revenue"] / g["orders"] print(monthly.round(1)) change = monthly.loc["May-Jun"] / monthly.loc["Jan-Apr"] - 1 print((change * 100).round(1).to_dict()) print(round(((1 + change["orders"]) * (1 + change["aov"]) - 1) * 100, 1))
Output orders revenue aov
period
Jan-Apr 167.2 13034.0 77.9
May-Jun 108.0 7353.8 68.1
{'orders': -35.4, 'revenue': -43.6, 'aov': -12.6}
-43.6Monthly orders fell from 167.25 to 108 (35.4 percent), monthly revenue from $13,034 to $7,354 (43.6 percent), and AOV from $77.93 to $68.09 (12.6 percent). The last line checks the breakdown: (1 − 0.354) × (1 − 0.126) − 1 = −0.436. The revenue drop is the product of the changes, not the sum of the percentages.
Here is a mistake to catch: "Revenue fell, so customers must be spending less." No: most of the revenue drop comes from the number of orders. The 12.6 percent fall in AOV also comes less from customers spending less on each purchase and more from fewer expensive Electronics orders. In lesson 22 you saw that the median order barely moved, from $44.95 to $44.85. The mean is sensitive to losing a few expensive orders, and the median is not (lesson 12). The sentence for the report: "In May to June, monthly orders fell 35 percent; the main source of the revenue drop (44 percent) is fewer orders."
How you write the number matters when you write this sentence for the board. Python prints 66843.57, and the board reads "$66.8 thousand". When you write a difference between rates, you separate percent from percentage points. You translate a p-value into everyday language. We will turn these into a checklist in step 7. Try matching them now.
Match each number with its correct form in the board report.
For each row, pick its match from the list, then check.
66843.570.050.05 / 0.13 = 0.385p = 0.0099 in the A/B testDid it fall by the same amount everywhere? If not, the place where it fell most is the closest clue to the cause. We will try two breakdowns: device (mobile, desktop) and customer cohort (lesson 40). The diagonal of a cohort table is the number of new customers in each month. A customer's cohort is the month of their first purchase, so counting customers by first-purchase month gives the diagonal directly.
Example 3 (case): Device breakdown and new customers
import pandas as pd o = pd.read_csv("orders.csv") o["date"] = pd.to_datetime(o["date"]) o["period"] = "Jan-Apr" o.loc[o["date"] >= "2026-05-01", "period"] = "May-Jun" t = o.groupby(["period", "device"]).size().unstack().loc[["Jan-Apr", "May-Jun"]] t = t.div(pd.Series({"Jan-Apr": 4, "May-Jun": 2}), axis=0) print(t) print(((t.loc["May-Jun"] / t.loc["Jan-Apr"] - 1) * 100).round(1).to_dict()) first_month = o.groupby("customer_id")["date"].min().dt.month print(first_month.value_counts().sort_index().tolist())
Outputdevice desktop mobile
period
Jan-Apr 65.5 101.75
May-Jun 53.5 54.50
{'desktop': -18.3, 'mobile': -46.4}
[127, 108, 117, 95, 48, 29]Monthly orders on mobile fell from 101.75 to 54.5 (46.4 percent), and on desktop from 65.5 to 53.5 (18.3 percent). The drop is on both devices, but on mobile it is two and a half times as steep. The number of new customers (the diagonal) is between 95 and 127 in January to April, then 48 in May and 29 in June. In the cohort table in lesson 40 you saw that returning old customers did not collapse in May and June. What fell is new customer acquisition. Part of the 127 in January comes from the start of the data window (someone who had bought before looks "new" in January), so April's 95 is a fairer point of comparison.
These two findings give two separate clues. If fewer new customers arrived, then fewer people may be coming to the store: that is a sign of traffic. If mobile fell much more than desktop, something must also have happened that affected only mobile.
The end of the ads reduces visitors on both devices. Even so, mobile fell 46 percent and desktop 18 percent. What is the first candidate for the extra drop on mobile?
The sentence for the report: "The drop is much steeper on mobile (46 percent) than on desktop (18 percent); new customers fell from 95 in April to 29 in June."
Exploration gave three suspects, and in lesson 22 you wrote them on hypothesis cards. Now we test each one with its own method. The most important rule of this step: the result of every hypothesis goes into the report, including the ones that are not supported. People think that "finding a single cause ends the analysis". At Bazaar, two causes work together, and saying that the third suspect was ruled out is also information for the board (otherwise someone withdraws the Electronics price increase for nothing).
| Card | Hypothesis | Method | Lessons |
|---|---|---|---|
| H1 | The ads stopped, so traffic fell | Daily averages of the two periods (ads, visitors) | 22, 41 |
| H2 | The new mobile checkout page lowered purchases | The April A/B test: two-proportion test and interval; difference-in-differences | 31, 42, previous lesson |
| H3 | The Electronics price increase reduced orders | Electronics against other categories on desktop; Fisher's exact test on mobile | 34, 37 |
Example 4 (case): Testing H1 and H2
import pandas as pd from statsmodels.stats.proportion import proportions_ztest, confint_proportions_2indep # H1: ads and traffic m = pd.read_csv("marketing.csv") m["period"] = "Jan-Apr" m.loc[m["date"] >= "2026-05-01", "period"] = "May-Jun" daily = m.groupby("period")[["ad_spend", "visitors"]].mean().loc[["Jan-Apr", "May-Jun"]] print(daily.round(1)) print("visitor change %", round((daily.loc["May-Jun", "visitors"] / daily.loc["Jan-Apr", "visitors"] - 1) * 100, 1)) # H2: the April A/B test (A old page, B new page) s = pd.read_csv("sessions.csv") k = s.groupby("group")["purchased"].agg(["sum", "count"]) z, p_value = proportions_ztest(k["sum"], k["count"]) low, high = confint_proportions_2indep(k.loc["A", "sum"], k.loc["A", "count"], k.loc["B", "sum"], k.loc[, ]) (k[].tolist(), (p_value, 4), (low * 100, 1), (high * 100, 1)) mobile, desktop = -46.4, -18.3 (, (mobile - desktop, 1))
Output ad_spend visitors
period
Jan-Apr 224.5 1553.3
May-Jun 24.5 1263.9
visitor change % -18.6
[65, 40] 0.0099 1.2 8.8
extra drop specific to mobile (points): -28.1H1. The average daily ad spend fell from $224.49 to $24.55, and daily visitors from 1,553 to 1,264 (18.6 percent). In lesson 41 you saw that the break came exactly on May 1, and that the 7-day average settled at the new level within a week. This is not an experiment, only a match in time. But the relationship between ads and visitors in lesson 36 points the same way, and so does the fact that the drop on desktop (18.3 percent) is almost the same as the drop in visitors (18.6 percent). Result: supported, in the language of "consistent with".
H2. In the April experiment, 65 of 500 sessions (13 percent) on the old page bought, and 40 of 500 (8 percent) on the new page. The difference is 5 points; the 95 percent confidence interval runs from 1.2 to 8.8 points, and p = 0.0099. This is an experiment: because the groups were assigned at random, we can speak causally and say "the new page lowered purchases". The page was still opened to everyone on May 1. The difference-in-differences from the previous lesson supports the same result from observational data: desktop (checkout page unchanged) fell 18.3 percent and mobile 46.4 percent, so mobile has an extra drop of about 28 points beyond desktop. This estimate rests on the assumption that the two devices would have moved in parallel if the page had not changed. A rough split is possible too: if the desktop rate (18.3 percent) applied to all orders, about 31 of the 167.25 monthly orders would go with traffic; the other 29 of the 59 lost orders are linked to the mobile-specific drop. So it is roughly half and half. Result: supported.
Example 5 (case): Testing H3
import pandas as pd from scipy import stats o = pd.read_csv("orders.csv") o["period"] = "Jan-Apr" o.loc[o["date"] >= "2026-05-01", "period"] = "May-Jun" o["segment"] = "other" o.loc[o["category"] == "Electronics", "segment"] = "Electronics" desktop = o[o["device"] == "desktop"].groupby(["period", "segment"]).size().unstack().loc[["Jan-Apr", "May-Jun"]] desktop = desktop.div(pd.Series({"Jan-Apr": 4, "May-Jun": 2}), axis=0) print(((desktop.loc["May-Jun"] / desktop.loc["Jan-Apr"] - 1) * 100).round(1).to_dict()) mobile = pd.crosstab(o.loc[o["device"] == "mobile", "period"], o.loc[o["device"] == "mobile", "segment"]).loc[["Jan-Apr", "May-Jun"]] print(mobile) print(round(stats.fisher_exact(mobile).pvalue, 3))
Output{'Electronics': -16.9, 'other': -18.9}
segment Electronics other
period
Jan-Apr 42 365
May-Jun 5 104
0.089H3. On desktop, Electronics orders fell 16.9 percent and other categories 18.9 percent: there is no sign that the price increase caused a drop specific to Electronics. On mobile, Electronics seems to have fallen sharply (from 42 orders to 5), but the numbers are small, and Fisher's exact test gives p = 0.089: a difference this large shows up from time to time even when there is no real difference. Result: not shown with this data. Be careful: "not shown" and "no effect" are not the same thing. The correct sentence: "In this data there is no evidence that the Electronics price increase reduced orders; on mobile there is a sign worth watching."
Use the block below to see the three results together. For each hypothesis, the code prints the result of the test and the sentence that goes into the report. Compare the language of the sentences: H2, which rests on an experiment, says "lowered", and the others say "consistent with" and "not shown".
Change the hypothesis: how do the test result and the report sentence change?
Pick a value; predict the output first, then look.
1hypothesis = "H1"2if hypothesis == "H1":3 before, after = 1553.3, 1263.94 change = round((after / before - 1) * 100, 1)5 result = "supported"6 sentence = f"After the ads stopped, daily visitors fell {abs(change)}%; the drop is consistent with lost traffic."7elif hypothesis == "H2":8 a, b, p = 65 / 500, 40 / 500, 0.00999 result = "supported" if p < 0.05 else "not shown"10 sentence = f"In the test, the new checkout page lowered purchases by {round((a - b) * 100)} points (interval 1.2 to 8.8 points)."11else:12 p = 0.08913 result = "supported" if p < 0.05 else "not shown"14 sentence = "On mobile, Electronics fell from 42 to 5, but the numbers are small; the effect of the price increase could not be shown with this data."15print(hypothesis, "→", result)16print(sentence)
H1 → supported After the ads stopped, daily visitors fell 18.6%; the drop is consistent with lost traffic.
Faded lines didn't run with this value. Three hypotheses, three methods, and three kinds of language. H2 rests on a randomly assigned experiment, so it can use a causal verb ("lowered"). H1 is a match in time; it says "consistent with". In H3, p = 0.089 > 0.05: the effect could not be shown, but that does not mean "no effect". All three go into the report.
During the analysis you found two things that are not directly about the main question but that the board should know. Side findings stay short in the report. They must not overshadow the main message, but they must not be left out either.
The first is shipping. In the survey, orders shipped with Caravan Freight had the lowest satisfaction. In lesson 39, when you added delivery time to the model, Caravan's gap became smaller and p became 0.12: the low satisfaction comes less from the company itself and more from delivery time (Caravan's packages arrive in 3.9 days on average, Arrow Express's in about 2.3 days). The recommendation is not to change the company but to set a delivery-time target.
The second is returns. 45 of the 64 returns, or 70 percent, are Clothing. The overall return rate looks higher on mobile than on desktop (7.9 percent against 6.2), but as you saw in lesson 37, this is Simpson's paradox: in every category, the return rate on mobile is lower, and the total comes out higher because 41.5 percent of mobile orders are Clothing, a category with a high return rate. The sentence "Mobile customers return more" would be wrong. The correct one is "Returns are concentrated in Clothing."
You have all the numbers. Now comes the hardest part: explaining them to a board that does not know statistics and has ten minutes. Two principles are enough.
First principle: answer first. The writing you learned at school starts with the method and ends with the result. A business report does the opposite: the first sentence is the answer, then comes the evidence that supports it, and the method and details come last (or in an appendix). A board member who reads only the first paragraph should still be able to decide. An executive summary gives, in order: the question, the answer, three pieces of evidence, the recommendation, and the limitation.
Compare them. A weak opening: "In our analysis, p-values and regression models were used. Sales collapsed by 41 percent, and the reason is the ads." These two sentences have four problems: it starts with the method (the board did not ask about p-values), it uses a cherry-picked number (41 percent), it blames a single cause (the ads), and it does not say what to do. A good opening: "Since May, monthly orders have fallen 35 percent. Roughly half of the drop comes from the traffic lost when the ads stopped, and a large part of the rest comes from the new mobile checkout page, which lowered purchases by 5 points in the April test. We recommend going back to the old checkout page right away and restarting the ad budget in measurable stages."
Second principle: write numbers for the reader. There are three rules. (1) Do not give more digits than the reader needs: write "$66.8 thousand", not 66843.57. Python's default output (0.0723, 66843.57) is for you, and a report needs a form made for people. (2) Separate percent from percentage points: a fall from 13 percent to 8 percent is a 5-point drop, and 38.5 percent in relative terms. If you write "5 percent", you shrink the effect to one eighth. (3) Give the uncertainty next to the number: "5 points (95 percent confidence interval: 1.2 to 8.8 points)". If an uncertain result is written as if it were certain, the first estimate that turns out wrong takes the trust in the whole report with it. In Python, f"{rate:.1%}" writes a rate as a percentage, and f"{amount:,.0f}" writes a number with thousands separators.
Try it now· not graded; doesn't affect progress
Run it, then change rate_b to 0.10: the difference falls to 3 points and the relative drop to 23.1 percent. Compare the plain Python format in the first line (8.0%, 66,844) with the report format in the other two lines. Be careful: f"{revenue:,.0f}" adds neither a dollar sign nor a unit, so you add them yourself.
Chart. One chart is enough in an executive summary, and its job is clear: to show the break. We adapt the chart you built in lesson 41 for the report: daily visitors in a light line, the 7-day average in a dark line, a dashed vertical line (axvline) on May 1, and a short note (annotate). The title follows the rule of lesson 17: not "Daily visitors", but a sentence that states the result.
Example 6 (case): The report chart
import pandas as pd import matplotlib.pyplot as plt m = pd.read_csv("marketing.csv", parse_dates=["date"]).set_index("date") m["avg7"] = m["visitors"].rolling(7).mean() fig, ax = plt.subplots(figsize=(9, 4)) ax.plot(m.index, m["visitors"], alpha=0.3, label="daily") ax.plot(m.index, m["avg7"], label="7-day average") ax.axvline(pd.Timestamp("2026-05-01"), color="gray", linestyle="--") ax.annotate("Ads ended, new checkout page", xy=(pd.Timestamp("2026-05-01"), 1700), xytext=(pd.Timestamp("2026-05-08"), 1750)) ax.set_title("Daily visitors fell from 1,553 to 1,264 after May 1 (19%)") ax.set_ylabel("visitors per day") ax.legend() print(m.loc[["2026-04-30", "2026-05-07", "2026-05-14"], "avg7"].round(0).tolist()) print(len(ax.get_lines()))
Output[1544.0, 1271.0, 1219.0]
3The 7-day average is 1,544 on April 30, 1,271 a week later, and 1,219 two weeks later: the change appears spread over a week, because each average contains the last seven days. There are three lines on the axes: two data lines and the vertical line drawn by axvline. The chart shows when the break happened. It does not show why. Two things changed on the same day, and the note on the chart and the text of the report say so.
Recommendations and limitations. A good recommendation says three things: what will be done, who will do it, and how success will be measured. "We should strengthen marketing" is a wish. "The product team goes back to the old checkout page this week; after two weeks, check whether the mobile conversion rate is close to its April level (13 percent)" is a recommendation. The same goes for the ads: instead of raising the budget to its old level all at once, switching it on in some cities and comparing with the others lets you measure the real effect of the ads with an experiment for the first time. Limitations are not the weak side of a report; they are the source of its credibility. For Bazaar, write at least three: the data covers only six months (seasonal effects cannot be separated), the survey covers only completed orders (the selection effect from the previous lesson), and the difference-in-differences estimate rests on the assumption that the two devices move in parallel.
The checklist comes from the six mistakes in the previous lesson. Before you hand in the executive summary, ask these six questions:
| Question | In the Bazaar report |
|---|---|
| Does the title state the result? | "Half of the sales drop comes from the ads, half from the new checkout page" |
| Does the first paragraph allow a decision on its own? | Question, answer, and recommendation in the first three sentences |
| Does each piece of evidence have a number and an interval or a comparison? | 5 points (1.2 to 8.8), mobile 46 percent / desktop 18 percent |
| Are percent and percentage points correct? | Purchases fell "5 points", not "5 percent" |
| Are causal sentences only on findings that rest on an experiment? | "Lowered" only for the A/B test; "consistent with" for the ads |
| Are there at least three limitations? | Six months, survey selection, the parallel-trends assumption |
You have finished Bazaar. Now show that the chain works somewhere else. A university dining hall ran a satisfaction survey among students in October (fictional sample data). Each row is one response: scores from 1 to 5 for taste, portion, cleanliness, price, and variety, the waiting time in the queue (in minutes; an optional question), and overall satisfaction (1 to 5). The dining hall manager's question: "Why is overall satisfaction low, and what should we do?"
The chain is the same, and the tools are familiar. Question and cleaning: forms submitted twice are deleted, and the missing values in waiting time are counted and deliberately left alone (the waiting question was optional, and filling in the gaps would be making up answers). Exploration: the mean and median of the overall score, and the correlation of the overall score with the other scores and with waiting time (lesson 36). Testing: turn the strongest relationship into a comparison of two groups and test it with Welch's t-test (lesson 32). Recommendation: four sentences. First, take a look at the data:
Try it now· not graded; doesn't affect progress
There are 355 responses and 13 columns; 12 rows are exact duplicates, and the waiting time has 24 empty cells (in the raw file; the number can change once the duplicates are removed, and you will find it yourself in the exercise). This is a survey, not an experiment: even if you find a strong relationship between waiting time and satisfaction, you cannot say "if we shorten the waiting time, satisfaction will rise". Students who come at crowded hours may also differ in other ways. Your recommendation should therefore be tied to a trial: open a second serving line for a month, and measure waiting time and satisfaction again. It is also written as a limitation that, because the survey was filled in voluntarily, unhappy students may be over-represented.
If you generate the sentence for the report from code instead of writing it by hand, the sentence updates by itself when the data changes. The f-string formats each number as it goes into the sentence: :,.2f for two decimals with thousands separators, :.1% for a percentage.
import pandas as pd o = pd.read_csv("orders.csv") o["period"] = "Jan-Apr" o.loc[o["date"] >= "2026-05-01", "period"] = "May-Jun" monthly = o.groupby("period").size() / pd.Series({"Jan-Apr": 4, "May-Jun": 2}) change = monthly["May-Jun"] / monthly["Jan-Apr"] - 1 sentence_3 = f"Average monthly orders were {monthly['Jan-Apr']:,.2f} in January to April and {monthly['May-Jun']:,.0f} in May to June: a {abs(change):.1%} drop." print(sentence_3)
OutputAverage monthly orders were 167.25 in January to April and 108 in May to June: a 35.4% drop.The {abs(change):.1%} part takes the size of the change (the minus sign is already carried by the word "drop") and writes it as a percentage with one decimal. If the data changes, the sentence changes with it. This is a small trick, but it keeps the sentences of a report consistent with its numbers.
Opening the report with the method and writing the uncertain as certain. A report that starts "In this study, a two-proportion test, Welch's t-test, and difference-in-differences were applied to 885 orders" answers a board member's first question (what happened, and what do we do?) on page three. Writing "The ads lowered sales by 18 percent" in the same report is also a mistake: the ads were never tested with an experiment, and the drop only matches them in time. The correct way: the first paragraph holds the answer and the recommendation; a causal verb ("lowered") only for a finding that rests on an experiment (the A/B test), and "consistent with" or "associated with" for the others; and an interval next to every estimate.
Next lesson: You have completed the course. Now you will build the same chain on your own in the projects, each with a different question and different data.
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.
rate, revenue, a, b = 0.0723, 66843.57, 0.13, 0.08 print(rate, revenue) print(f"{rate:.1%}", f"${revenue:,.0f}", f"${revenue / 1e3:.1f} thousand") print(f"Difference: {(a - b) * 100:.0f} points; relative drop: {(a - b) / a:.1%}")
Output0.0723 66843.57
7.2% $66,844 $66.8 thousand
Difference: 5 points; relative drop: 38.5%f"{0.0723:.1%}" multiplies the rate by 100, rounds it to one decimal, and adds %: 7.2%. f"${66843.57:,.0f}" rounds to a whole number and adds thousands separators, and dividing by 1e3 before formatting gives the "thousand" form a board reads quickly. The same approach works for a bank's interest rate, the pass rate of an exam, or the response rate of a survey.