Chapter 3 Discussion Guide — Python and pandas for Cricket
Chapter link: Chapter 3
Framing question
"Which is more dangerous to an analyst: code that crashes, or code that runs perfectly and gives a plausible wrong number?"
A coding chapter still deserves discussion. This guide uses short, concrete prompts that make students articulate why each habit matters.
Discussion questions
Tier 1 — Recall
1. Why does the book's strike-rate function return None rather than 0 when a batter has faced no balls?
Facilitator notes: A batter run out at the non-striker's end without facing has 0 balls. Returning 0 claims he faced balls and blocked them all; None (or pandas' NaN) says "undefined". Choosing what to return for the impossible case is an analytical decision.
Likely answers: "To avoid a ZeroDivisionError." Push for the second half: why is 0 wrong, not just inconvenient?
2. Kohli's IPL strike rate is 134.80. What number do you get if you count wides as balls faced, and why does no error appear? Facilitator notes: 131.07 (7,123 balls instead of 6,926). Runs off the bat on a wide are zero, so only the denominator changes. Nothing crashes. Likely answers: Most will remember the number. Ask them to name two other silent bugs from the chapter (season as text; super overs, which give 134.86).
3. Why does season == "2020" return zero IPL matches?
Facilitator notes: The 2020 season is stored as "2020/21" (played September–November 2020). The fix: build a year from start_date.
Likely answers: Quick recall; use it to reinforce "an empty result is a bug until proven otherwise".
Tier 2 — Analysis
4. The IPL 2026 death-overs run rate appears as 10.32 in one table and 10.79 in another. Which is right? Facilitator notes: Both. 10.32 is runs on legal balls only; 10.79 is all runs (including wides and no-balls) per legal ball. The question decides the filter. Likely answers: Students often call one a bug. Have them state, in one sentence each, the question each number answers.
5. Kohli's 43 off 35 in the 2025 final had 27.9% of its runs in boundaries, against 56.47% across his IPL career. RCB won by six runs. Was it a good innings? Facilitator notes: The data describes how he scored (running, not hitting) but not whether that was right. Exercise B1 says Chapter 9 gives the tools to measure it. Likely answers: "We won, so yes" — a chance to name outcome bias. "Too slow" — ask what the side needed at the time.
6. In the 2025 final, Punjab needed 55 off 24 with six wickets in hand after 16 overs and 47 off 18 with four in hand after 17. The required rate rose about 1.9 an over. Why did the over feel much bigger than that? Facilitator notes: Two wickets fell. The required rate ignores wickets; win probability (Chapters 9 and 20) combines both. Likely answers: Good students say "the set batters were gone". Ask how you would put a number on that.
7. Why does every leaderboard in the chapter need a minimum number of balls? Facilitator notes: Without one, a batter who faced 11 balls tops a strike-rate table (Exercise D4). The minimum and the sample should appear next to every rate. Likely answers: "To filter out flukes." Ask: who chooses the minimum, and how? (Chapter 6 gives a principled answer.)
Tier 3 — Settle this debate
8. "In the modern IPL, 200 batting first wins you the match." Facilitator notes: The chapter's answer: across 2008–2026, 200+ was defended 161 of 212 times (75.9%); in 2026 only 20 of 37 (54.1%). In 2024–26, 200–219 won 61.7% (47 totals) and 220+ won 75.0% (48). Under 180, 13.0% (77). Likely answers: Students will split on whether 54.1% "settles" it. Raise sample size (37 totals) and the 2023 rule change.
9. "Learning to code is a waste of time for a cricket fan or coach — the websites already have the numbers." Facilitator notes: Draw on the chapter's examples of numbers the websites do not show (phase dot and boundary shares, custom bands, reconciling a scorecard). Also acknowledge the cost in time. Likely answers: Coaches and journalists in the class may push back usefully. Ask each side for one question they could only answer with code.
Role-play — Wendell and the rebuilt scorecard
Setup (10 minutes). Use the chapter's Eye test dialogue. One student is Nusrat with the rebuilt 2025 final scorecard (Krunal Pandya 4–0–17–2, player of the match). One is Wendell asking "Where did Krunal bowl?" A third student is a broadcast producer who needs three talking points for a highlights package in five minutes.
Rules: Nusrat may answer only with what the 252 rows contain. Wendell may ask anything. The producer chooses which of Nusrat's facts and which of Wendell's questions make the package.
Debrief: Wendell's line — "Your numbers tell me where to point my eyes." What would the producer have missed with only one of the two?
Eye test vs data prompt
"Wendell says the scorecard is complete about the things it records — more than his memory is — and a blank page on causes. Name one moment from a match you watched where your memory and the scorecard disagreed. Which one turned out to be right?"
Encourage specific matches. The point is not that memory is useless, but that a complete outcomes record is a check on it.
Exit ticket
- Rewrite this so it runs:
balls[balls["over"] > 15 and balls["season"] == "2026"]. - Name one silent bug and the check that would catch it.
- One cricket question you now want to answer with pandas.