Chapter 2 Exercises — Cricket Data, the Toolkit, and Your First Analysis
Difficulty: ⭐ recall and explain · ⭐⭐ compute and interpret · ⭐⭐⭐ build or judge · ⭐⭐⭐⭐ open-ended project
All numbers come from the chapter's script outputs (Cricsheet snapshot, November 2026). Short
answers to Part B are in <details> blocks; selected answers to other parts are in
Appendix I.
Part A — Conceptual ⭐
A1. Explain the difference between a delivery and a legal delivery. Give one example of a delivery that is not legal and one example of a legal delivery on which the batter scores no runs but the batting side does.
A2. The chapter describes four kinds of cricket data source (ball-by-ball files, web statistics databases, subscription scorecard archives, and ball-tracking). For each, name one question it answers well and one it cannot answer.
A3. Cricsheet's data is released under the Open Data Commons Attribution License. In your own words, what does that licence let you do, and what does it ask of you in return?
A4. The toolkit's download() and build() both begin with "if the file already exists and
force is false, return". Explain why this pattern matters for (a) a reader on a slow connection and
(b) the reproducibility of the book's printed numbers. What is the risk it creates?
A5. Why does the toolkit add 1 to Cricsheet's over number? Give one analysis in later chapters that would be silently wrong if it didn't.
A6. ball_in_over and legal_ball_index both describe "which ball". Explain the difference and
say which one you'd use to compute "balls remaining in a T20 innings".
A7. Why does batting_summary count outs using player_out rather than batter? Describe the
cricket situation that makes this necessary.
A8. The toolkit keeps only the first wicket on a delivery. Why is that an acceptable simplification for this book? What makes it recoverable?
A9. Give three things Cricsheet does not record that a franchise analyst with a ball-tracking feed would have. For each, name the chapter of this book that deals with the gap.
A10. "Names are not identities." Explain what this means in the context of Cricsheet, using the three "Rashid Khan"s in men's T20Is as your example.
Part B — Calculation & Interpretation ⭐⭐
B1. The first over of the IPL 2026 final contained these deliveries (runs off the bat, extras): (0,0), (0,0), (4,0), (4,0), (0, 1 wide), (0, 1 wide), (1,0), (0, 1 wide), (1,0). (a) How many deliveries and how many legal balls? (b) Total runs in the over? (c) Runs conceded by the bowler? (d) The bowler's economy rate for this over?
Answer
(a) 9 deliveries, 6 legal balls. (b) 0 + 0 + 4 + 4 + 1 + 1 + 1 + 1 + 1 = 13. (c) All 13 — wides are charged to the bowler and there were no byes or leg-byes. (d) 6 × 13 / 6 = 13.00 an over.
B2. From the timing table: parsing the men's Tests archive took 15.8 s and reading the Parquet cache 0.66 s; the cache is 11.2 MB on disk but 1,970 MB in memory with all 42 columns and 240 MB with five. (a) How many times faster is the cached read? (b) What fraction of the full in-memory size does the five-column read use? (c) If your laptop has 4 GB of RAM, why does (b) matter more than (a)?
Answer
(a) 15.8 / 0.66 ≈ 24×. (b) 240 / 1,970 ≈ 12%. (c) A slow load wastes seconds; running out of memory makes the computer swap to disk or crash. Loading 2 GB for one table on a 4 GB machine leaves little room for anything else.
B3. Of 45,276 completed (non-final) IPL overs, 4 had five legal balls and 4 had seven. (a) What percentage of overs were miscounted? (b) If you computed balls remaining as 120 − 6 × (overs completed), how far off would you be after a seven-ball over?
Answer
(a) 8 / 45,276 ≈ 0.018% — about one over in 5,700. (b) One ball: the formula assumes six legal balls were bowled, but seven were, so it overstates balls remaining by 1 (and understates it by 1 after a five-ball over).
B4. The dismissal mix table shows lbw at 16.6% of dismissals in men's Tests and 6.0% in the IPL; run-outs at 2.6% and 8.1%. (a) By what factor is lbw more common (as a share) in Tests? (b) Run-outs in the IPL? (c) Give a cricket explanation for each.
Answer
(a) 16.6 / 6.0 ≈ 2.8×. (b) 8.1 / 2.6 ≈ 3.1×. (c) Test batters defend more balls on length and leave or pad up more, so more balls hit the pad in line; T20 batters move around the crease and swing, so fewer balls strike the pad. White-ball batters take more risks running to keep the score moving; Test batters rarely need to.
B5. IPL 2026: Vaibhav Suryavanshi 776 runs off 327 balls; Shubman Gill 732 off 449. (a) Compute both strike rates. (b) How many more balls did Gill use? (c) If the balls Gill used beyond Suryavanshi's total had instead been faced by a batter at the IPL 2026 overall run rate of 9.91 runs per six balls, how many runs would they have produced? What does (c) suggest about comparing the two by runs alone?
Answer
(a) Suryavanshi 100 × 776 / 327 = 237.31; Gill 100 × 732 / 449 = 163.03. (b) 449 − 327 = 122 balls. (c) 122 × 9.91 / 6 ≈ 201.5 runs. Runs alone ranks them 776 v 732, nearly level; accounting for the balls consumed, Suryavanshi's season left room for about 200 more runs from teammates at the league rate. (This "runs above a baseline for the balls used" idea is developed in Chapters 8 and 13.)
B6. WPL 2026: Lauren Bell bowled 36 overs (216 balls) for 199 runs and 12 wickets with 59.26% dot balls; Sophie Devine bowled 32.5 overs for 272 runs and 17 wickets. (a) How many balls did Devine bowl? (b) Compute both economy rates and bowling strike rates. (c) Which bowler would you rather have, and what further information would change your mind?
Answer
(a) 32 × 6 + 5 = 197 balls. (b) Bell: economy 6 × 199 / 216 = 5.53, strike rate 216 / 12 = 18.0. Devine: economy 6 × 272 / 197 = 8.28, strike rate 197 / 17 = 11.6. (c) Devine takes a wicket every 11.6 balls; Bell concedes 2.75 fewer runs an over. It depends on the phase each bowled in (death overs inflate economy) and on the value of a wicket versus a run — the trade-off Chapter 14 quantifies. With 12 and 17 wickets, both samples are small.
B7. The IPL 2026 sanity check printed: runs off the bat 26,151 + extras 1,299 = total 27,450. In the 2026 final the extras were 5 wides and 2 leg-byes. (a) What share of all IPL 2026 runs were extras? (b) Why is the sanity check worth running even though it "obviously" adds up?
Answer
(a) 1,299 / 27,450 ≈ 4.7%. (b) Because it would catch a broken filter, a double-counted delivery, a dropped super-over condition, or a column misread — mistakes that leave every individual number plausible but the parts no longer summing to the whole.
B8. The Mirpur Test (Case Study 2): Bangladesh 413 (117.1 overs) and 240 for 9 declared (70.3 overs); Pakistan 386 (100.3 overs) and 163 (52.5 overs). (a) What target did Pakistan need? (b) Convert each innings' overs label to legal balls. (c) Which innings had the highest run rate? (d) How many legal balls did the whole match contain, and how does that compare with the median Test in the snapshot (1,949)?
Answer
(a) Lead 413 − 386 = 27; 27 + 240 = 267 ahead; target 268. (b) 117.1 → 703; 100.3 → 603; 70.3 → 423; 52.5 → 317 (overs × 6 + balls). (c) Pakistan's first innings: 6 × 386 / 603 = 3.84. (d) 703 + 603 + 423 + 317 = 2,046 — about 5% more than the median Test.
Part C — Code It ⭐⭐–⭐⭐⭐
Each task extends one of the chapter's scripts. Copy the standard header (Chapter 2, §2.2) into a new file in your own folder.
C1. Analyze this match ⭐⭐. Adapt code/case_study_01.py to the WPL 2026 final (find it with
load_matches("wpl") and stage == "Final"; the season label is "2025/26"). Output: the innings
totals table, a phase split table (powerplay / middle / death runs, wickets, legal balls, run rate)
and a Manhattan chart saved as wpl_final_manhattan.png. Expected shape: 2 innings rows; 6 phase
rows (fewer if the chase ended early); one figure.
C2. Build this metric ⭐⭐. Write a function extras_profile(code) that returns, for each season
(use Crease's add_season_year to get integer years), wides, no-balls, leg-byes and byes per 120
legal balls rather than per match. Run it for the IPL, the BBL and the WBBL. Expected shape: one row
per season per competition, four rate columns. Plot wides per 120 balls for the three leagues on one
chart. Does the IPL's post-2021 rise in wides appear in the other leagues?
C3. Build this metric ⭐⭐. Extend code/04_data_quality.py to report, for every competition
in the snapshot, the number of completed overs with fewer or more than the expected legal balls (5 in
The Hundred's sets, 6 elsewhere) and the rate per 10,000 overs. Expected shape: 20 rows, columns
overs_checked, short, long, rate_per_10k. Which competition has the highest rate? Suggest one
data reason and one cricket reason.
C4. Evaluate this player ⭐⭐⭐. Using the batter and batter_id columns of
load_deliveries("t20s_female"), find every batter name in women's T20Is that maps to more than one
id. For each, produce a batting_summary by name and by batter_id, and a third version after
only_player(balls, name). Expected
output: a table of colliding names with the number of identifiers, and for the most-affected name, the
"merged" line next to the true per-person lines.
C5. Settle this debate ⭐⭐⭐. "Women's T20Is have more run-outs because the standard is lower." Use the dismissal-mix code to compute run-out share for women's T20Is (a) among matches between teams that also appear in the WPL or WBBL as nationalities — simplify this to matches where both teams are in {Australia, England, India, New Zealand, South Africa, West Indies, Sri Lanka, Pakistan, Bangladesh, Ireland}, and (b) in all other matches. Expected output: a 2 × 6 table of dismissal shares and the number of dismissals in each group. Does the run-out gap survive? What would you still need to control for?
C6. Predict this match ⭐⭐. Use season_table("ipl") and season_table("psl") from Crease to
compare average first-innings totals by year. Fit nothing yet — just plot both series and the
difference. If you had to guess the IPL 2027 average first-innings total from the table alone, what
would you guess and why? (Chapter 25 returns to this with a proper projection method; record your
guess now.)
C7. Optimize this strategy ⭐⭐⭐. Memory budget: write a function load_lean(code, columns) that
reads only the given columns from Parquet and converts every text column with fewer than 5,000
distinct values to pandas' category dtype. Report the in-memory size of the men's Tests deliveries
table (a) with all columns, (b) with your ten most useful columns, (c) with those ten as categories.
Expected output: three numbers in MB. Which change saved more — fewer columns or categories?
Part D — Judgment & Format Transfer ⭐⭐⭐
D1. The toolkit labels T20 overs 16–20 as "death". Would a "death overs" label make sense in a Test? In an ODI, the toolkit uses overs 41–50. Argue whether 41–50 or 46–50 better captures what a coach means by "the death" in ODI cricket, and how you could use the data to decide.
D2. Wendell says: "Your table tells me Rabada went for 37 in two overs of the final. I watched it. Half of those runs were edges past the keeper." Can the Cricsheet data confirm or refute him? What data would? What should an analyst do with an eye-test claim the data can't check?
D3. A colleague proposes dropping all matches decided by D/L from every analysis "to keep things
clean". Using the chapter's numbers (23 D/L results in 1,243 IPL matches) and the same count for men's
T20Is (compute it from load_matches("t20s_male")["method"]), argue for and against. Would your answer differ for a study of chasing strategy?
D4. Afghanistan's men's internationals are withheld from Cricsheet. You are asked to rank the best T20I spinners of 2020–2026 using this book's data. Write the caveat paragraph you would attach to the ranking, and suggest one way to reduce the problem using data that is in the snapshot.
D5. The Hundred is stored with match_type = "T20", 5-ball "overs", and men's and women's
matches in one archive. A colleague runs load_many(["ipl", "bbl", "hnd"]) and computes "T20
death-overs strike rate" by filtering phase == "death". List everything that is wrong or
misleading about the result, and rewrite the filter so the comparison is fair.
Part M — Mixed / Interleaved ⭐⭐–⭐⭐⭐
M1 (with Chapter 1). Chapter 1 argued that the numbers everyone quotes are often wrong. Using
batting_summary on the IPL, compute Virat Kohli's IPL career runs, outs, average and strike rate,
and compare them with any figure you can find quoted in a newspaper or broadcast. If they differ,
list every definitional reason from §2.7 that could explain the gap (super overs, retired hurt, data
coverage, the season label).
M2 (with Chapter 1). Chapter 1 introduced the IPL scoring revolution — average first-innings
totals rising from 157.5 in 2012 to 195.7 in 2026. Reproduce those two numbers with Crease's
season_table("ipl"), then change the filter to include D/L matches and ties. How much do the two
numbers move? Which filter would you put on a broadcast graphic, and why?
M3 (looking ahead to Chapter 3). Rewrite season_leaders from code/06_first_analysis.py without
using batting_summary — compute runs, balls (excluding wides), outs (by player_out, excluding
retired hurt) and strike rate yourself with groupby. Check your output matches the toolkit's for IPL
2026 exactly. Every mismatch is a definition you've missed.
M4 (looking ahead to Chapter 5). Using the per-match volume table (median legal balls: Test 1,949; ODI 557; T20I 231), estimate how many matches of each format you'd need to observe 10,000 legal balls from one team. Then explain why a player's T20 "career" of 100 innings can still be a smaller sample than it sounds.
M5 (looking ahead to Chapter 6). Harmanpreet Kaur's WPL 2026 average was 68.40 on five dismissals. If one of her not-out innings had instead ended in a dismissal at the same score, what would her average have been? What does that sensitivity tell you about quoting single-season averages?
Answer to M5
342 runs / 6 outs = 57.00 instead of 68.40 — one result changes the average by 11.4 runs. With five dismissals, a single innings swings the number enormously; Chapter 6's shrinkage methods exist for exactly this.
Part E — Research & Extension ⭐⭐⭐⭐
E1. The women's data audit. Run the full audit checklist from the Chapter Summary on the
women's archives — t20s_female, odis_female, wpl, wbb and the women's matches inside
hnd. Produce: an inventory table, season-label quirks, results and D/L counts, over-length
anomalies, missing-value counts, name collisions, and a dismissal mix. Write a 1,000-word data
note: what a researcher should know before analysing women's cricket with Cricsheet data.
E2. Cross-check against a reference. Choose 20 players across formats and genders (include at
least five women and at least five players from Bangladesh, Sri Lanka, Zimbabwe, West Indies or
Ireland). For each, compute a career line with the toolkit for one format, then look up the same
line on ESPNcricinfo using the player's key_cricinfo from the people register. Tabulate the
differences and classify each one: coverage (matches missing from Cricsheet), definition (e.g.
retired hurt), or unexplained. Report what fraction of differences you can explain.
E3. A new league. Pick a T20 competition that Cricsheet publishes but this book's snapshot does
not include. Download it with cricdata.download(code) — check Cricsheet's downloads page for the
archive name rather than guessing — build it with cricdata.build(code), and run the chapter's
inventory, audit and leaders scripts on it. What did you have to change, if anything?
Selected answers and hints
Part A — short answers
A1. A delivery is any ball bowled; a legal delivery is one that counts toward the six-ball over (not a wide, not a no-ball). Not legal: a wide down the leg side. Legal with no runs to the batter but runs to the side: a leg-bye or a bye — the ball counts, the runs go to extras.
A2. Ball-by-ball files (Cricsheet): good for phase strike rates and match-state analysis; can't give pre-2001 Test history or line and length. Web databases (Statsguru, Howstat): good for long career records and official aggregates; poor for ball-level questions and not built for bulk download. Subscription archives (CricketArchive): good for obscure and domestic scorecards; usually no ball-by-ball detail. Ball-tracking: good for pitch maps, speed, swing; not public, so a fan can't analyse it.
A3. You may copy, share, adapt and build on the data, including commercially, provided you credit the source. Read the licence text included in each archive for the exact terms.
A4. (a) It avoids re-downloading tens of megabytes on every run. (b) It pins the data: the numbers printed in the book stay reproducible because your cache doesn't silently change. The risk is staleness (new matches and Cricsheet's revisions don't arrive until you force a refresh) and the half-downloaded file that is never replaced.
A5. Cricsheet numbers overs from zero; commentators and the Laws' playing conditions use 1-based
overs. Without the + 1, the T20 powerplay test over <= 6 would include the seventh over, and
every phase split, death-overs strike rate and powerplay economy in the book would be wrong.
A6. ball_in_over is the legal ball being bowled (illegal deliveries repeat the next number);
legal_ball_index is the running count of legal balls in the innings, blank on wides and no-balls.
For balls remaining, use legal_ball_index (or a cumulative count of is_legal), never over numbers.
A7. A non-striker can be run out (backing up, or in a mix-up) on a delivery someone else faced.
Counting by batter would wrongly charge the striker with the dismissal and give the non-striker
none.
A8. It affects 13 deliveries in 6.4 million across the snapshot, none in the IPL. It's
recoverable because n_wickets_on_ball records how many wickets fell, so you can find the 13 rows
and go back to the JSON for the second dismissal.
A9. Line and length (Chapter 15), shot direction (Chapters 7 and 32), ball speed and movement (Chapter 15, described), fielding positions (Chapter 32), dropped catches and misfields (Chapter 17).
A10. The delivery tables carry display names, not identifiers. In men's T20Is three different
players — one each for Belgium, Nepal and the ICC World XI — appear as "Rashid Khan", so a summary
by name merges them into one fictional bowler (5 matches, 6 wickets, economy 10.37). The people
register gives the identifiers that separate them, and the toolkit copies them onto every
delivery (bowler_id), so bowling_summary(..., by="bowler_id") or only_player() splits them.
Part C — hints
C1. games = load_matches("wpl"); fid = games.loc[(games["season"] == "2025/26") & (games["stage"]
== "Final"), "match_id"].iloc[0]. If stage is empty for that season, sort the season's matches by
start_date and take the last one, then confirm with the event_name and the teams.
C2. Per 120 legal balls means 120 * wides_runs / legal_balls within each season. Group on
["year"] after add_season_year, summing the extras columns and is_legal. Exclude super overs.
C3. For The Hundred, the "over" in Cricsheet is a five-ball set (balls_per_over == 5 in the
matches table) — read the expected length from that column rather than hard-coding it. Exclude the
last over of each innings, which can legitimately be short.
C4. balls.groupby("batter")["batter_id"].nunique() finds the colliding names. Then
batting_summary(balls[balls["batter"] == name], by="batter_id") gives the per-person lines. Note
that batting_summary counts outs by player_out, so for the by-id version you may want to check
player_out_id too — only_player() handles all four name columns for you.
C5. Build a boolean column both_full with isin on team1 and team2 of the matches table,
merge it onto deliveries by match_id, and compute the dismissal mix within each group. Report the
counts, not just the percentages: a 14% share of 200 dismissals and of 20,000 are very different
evidence.
C7. df[col].astype("category") stores each distinct string once and replaces the column with
small integer codes. df.memory_usage(deep=True).sum() / 1e6 gives megabytes. Expect column
selection to give the bigger saving, and categories to give a further large cut on name columns like
batter and bowler.
Part D — a model answer sketch for D2
Cricsheet can confirm the runs and that no wicket fell in those overs; it can't tell an edge from a middled drive, because it records outcomes, not contact or direction. Ball-tracking or a hand-charted shot dataset ("edged / beaten / middled" for each ball) could test the claim. The analyst should treat the coach's observation as a hypothesis worth recording, not as something to dismiss because the data can't see it — and should be careful not to present the economy figure as proof that the bowler "bowled badly". Over many matches, a bowler whose runs come disproportionately from edges would be expected to regress toward better figures; that's a Chapter 6 idea, and a reason the eye test and the numbers belong in the same conversation (Theme 5).