AI Hints
Home›Data Science Tutorial›Case Study: The Summer Panic
Data Science · Lesson 83 of 101

Case Study: The Summer Panic

Is the business falling apart?.

⏱ 3 min read▶ Video at 2:18:56🎓 Free
Watch this lesson in the Data Science courseWatch on YouTube ↗Full Data Science course

It's October. The founder storms in, holding a chart. Revenue has dropped seventeen percent since the first quarter. The bank's nervous, and the board wants answers by Friday. Someone suggests cutting staff. Someone else suggests a big discount campaign. Before anyone does anything, you ask for a day with the data. Let's work through this exactly as a professional would.

Case Study: The Summer Panic
From the video: Case Study: The Summer Panic
  • Revenue down seventeen percent
  • The board wants answers
  • You ask for a day with the data

Step one: see the whole picture

First, look at every quarter, rather than the two in the founder's chart. Revenue, profit, and margin. Run it. Yes, the third quarter of twenty twenty five is well below the first. But look across the rows. Twenty twenty four did exactly the same thing. High in the winter, low in the summer, and high again. The margin is rock steady, at sixty five percent. So nothing's wrong with pricing or costs. The founder compared a winter with a summer. Already, this looks more like a calendar than a crisis.

case1_step1.pypython
import pandas as pd

s = pd.read_csv("sales.csv", parse_dates=["date"])
s["q"] = s["date"].dt.to_period("Q").astype(str)
t = s.groupby("q")[["revenue", "profit"]].sum()
t["margin"] = t["profit"] / t["revenue"]
print(t.round(3).to_string())
Output
          revenue     profit  margin
q
2024Q1  801588.87  520693.47   0.650
2024Q2  671453.76  436201.66   0.650
2024Q3  660612.86  429076.76   0.650
2024Q4  865428.38  562362.28   0.650
2025Q1  922777.44  599256.64   0.649
2025Q2  777956.73  505501.83   0.650
2025Q3  763405.81  495768.01   0.649
2025Q4  989899.88  643035.28   0.650

Step two: is the drop everywhere?

A real problem usually has a location. One region. One product. So we split the drop. Run it. Africa is down eighteen percent. Americas, seventeen. Asia, seventeen. Europe, seventeen. And coffee, food, and tea are all the same. When every region and every product falls by the same amount at the same time, it isn't a local failure. It's something that affects everything, like the season. If it had been only Europe, or only coffee, we'd have had a very different conversation.

case1_step2.pypython
import pandas as pd

s = pd.read_csv("sales.csv", parse_dates=["date"])
s["q"] = s["date"].dt.to_period("Q").astype(str)
a, b = s[s.q == "2025Q1"], s[s.q == "2025Q3"]

for col in ["region", "category"]:
    x = pd.DataFrame({"Q1": a.groupby(col)["revenue"].sum(), "Q3": b.groupby(col)["revenue"].sum()})
    x["change"] = (x["Q3"] / x["Q1"] - 1).round(3)
    print(x.round(0).assign(change=x["change"]).to_string())
Output
                Q1        Q3  change
region
Africa    233550.0  192255.0  -0.177
Americas  163424.0  134830.0  -0.175
Asia      202461.0  166951.0  -0.175
Europe    323342.0  269371.0  -0.167
                Q1        Q3  change
category
Coffee    606118.0  501430.0  -0.173
Food      260459.0  215602.0  -0.172
Tea        56201.0   46374.0  -0.175

Step three: the fair comparison

The right comparison is the same month, one year earlier. That removes the season. Run it. January was up seventeen percent on the year before. April, up fifteen. July, up sixteen. October, up fourteen. The business isn't falling at all. It's growing by about fifteen percent. In fact, July was one of the strongest months of growth. But look at the last rows. Growth has slowed from seventeen to about thirteen. That's a real and much more useful finding, and nobody had noticed it, as they were looking at the wrong chart.

case1_step3.pypython
import pandas as pd

s = pd.read_csv("sales.csv", parse_dates=["date"])
s["m"] = s["date"].dt.month
m = s[s.date.dt.year == 2024].groupby("m")["revenue"].sum()
n = s[s.date.dt.year == 2025].groupby("m")["revenue"].sum()
print(pd.DataFrame({"2024": m, "2025": n, "growth": (n / m - 1).round(3)}).iloc[[0, 3, 6, 9, 11]].round(0).assign(growth=(n / m - 1).round(3)).to_string())
Output
        2024      2025  growth
m
1   275833.0  323598.0   0.173
4   236546.0  273201.0   0.155
7   208514.0  242684.0   0.164
10  266335.0  304887.0   0.145
12  314770.0  356262.0   0.132

Step four: test the proposed cure

Someone wanted a discount campaign. Before we recommend anything, what do our past discounts show? We compare days with a discount, and days without one. Run it. With no discount, an average of twenty two point one units. With ten percent off, twenty two point two. Discounts barely changed the number sold. But the margin fell from sixty five percent to sixty one. So the suggested cure would have cost money, and bought nothing. To be careful, this isn't an experiment, so we'd want to test that properly. But nothing here supports running a campaign.

case1_step4.pypython
import pandas as pd

s = pd.read_csv("sales.csv", parse_dates=["date"])
d = s.groupby(["date", "discount"])[["revenue", "units"]].sum().reset_index()
t = s.groupby("discount").agg(rows=("units", "size"), units=("units", "mean"), margin=("profit", "sum"), rev=("revenue", "sum"))
t["margin"] = (t["margin"] / t["rev"]).round(3)
print(t[["rows", "units", "margin"]].round(2).to_string())
Output
           rows  units  margin
discount
0.0       64552  22.12    0.65
0.1        5624  22.20    0.61

The one-page answer

Here's what goes to the board. Recommendation, no cuts, and no discount campaign. Why? The drop is seasonal, and it happened last year too. Year on year, we're up about fifteen percent. Margins are steady at sixty five percent. Past discounts lifted units by almost nothing. Watch item, growth is slowing, from seventeen to thirteen percent, so we should find out why. A panic has become a calm plan, with one real question.

Recommendationno cuts, no discounts
Findingseasonal drop, 15% growth
Evidenceevery region fell equally
Watch itemgrowth is slowing

Summary

Whole picture, slice it, compare fairly, and test the cure. Those four steps can defuse almost any panic. Next, a problem about people. Who should be on shift?

Key takeaways
  • Look at all periods
  • Real problems have a location
  • Compare with last year
Next up: Case Study: Staffing the Cafes — where are we over and under?