65 min read

Here is a question with an easy answer: who won the 2023 Open Championship at Royal Liverpool?

Chapter 2 — The Golf Analytics Toolkit: Scoring Data, Simulated Shot Data, and the Python Pipeline Behind This Book

Here is a question with an easy answer: who won the 2023 Open Championship at Royal Liverpool?

Brian Harman did. He shot 271, thirteen under par, and won by six. You can look it up anywhere.

Now ask the data. When this book's pipeline first turned ESPN's raw JSON into tables, the column called won said the 2023 Open was won by Shubhankar Sharma. Sharma played well that week. He shot 279 and finished eighth. But he was not the champion, and the table was wrong.

The error is worth looking at closely, because it is the kind of error that hides in every golf dataset. Here is what the first pass of the table said about the top of the 2023 leaderboard, next to what the corrected columns say (code/03_snapshot_and_quirks.py):

ESPN order player raw status raw won corrected status_fixed corrected position 72-hole total
1 Brian Harman WD/DQ False finished 1 271
2 Tom Kim WD/DQ False finished 2 277
3 Jason Day WD/DQ False finished 2 277
4 Sepp Straka WD/DQ False finished 2 277
5 Jon Rahm WD/DQ False finished 2 277
6 Rory McIlroy WD/DQ False finished 6 278
7 Emiliano Grillo WD/DQ False finished 6 278
8 Shubhankar Sharma finished True finished 8 279

Seven of the top eight players are labelled as withdrawals. Nobody in that group withdrew. What happened is simpler and sneakier. ESPN's file for that week holds every player's round score and the strokes on every hole. But on hundreds of hole records the score-relative-to-par tag makes no sense: a 3 tagged "+2" implies a par 1. The first-pass build derived each hole's par from that tag and set aside the holes where it couldn't, so in its tables most players were missing one or more hole-by-hole scorecards. In rounds 1 and 2, only 85 of the 156 players had a complete 18-hole scorecard. The build then followed a reasonable-sounding rule: "if a player has an incomplete round, he must have withdrawn." By that rule 85 of the 156 entrants "withdrew", and the first player in ESPN's order with four clean scorecards was Sharma, so he became the winner.

Every number in that story is real, and so is the lesson. Data does not arrive correct. It arrives with a shape, and you have to learn the shape before you trust a single number. The corrected columns (status_fixed, won_fixed and friends) check each player's actual round scores and ESPN's own leaderboard order, and they put Harman back on top: 76 finishers and 80 missed cuts, with no withdrawals at all. The final build goes one step further. It recovers the pars that the bad tags hid, so every 2023 Open scorecard is now complete, and the raw won column names Harman too. Case Study 1 tells that story.

This chapter is the map of the data that the rest of the book stands on. You will see where every number comes from:

  • the free ESPN JSON that gives us 23 seasons of real PGA TOUR scores, hole by hole;
  • the scripts that download it politely and turn a gigabyte of nested JSON into eight megabytes of tidy tables;
  • every quirk we found, with a count next to it;
  • what is not free (shot-level ShotLink data and strokes gained by category), and why;
  • the shot simulator that fills that gap honestly, with every simulated number labelled;
  • the data model you will use for your own rounds, and the validation code that catches your typos before they become "insights".

If Chapter 1 was about the physics of one ball, this chapter is about the plumbing behind 7.5 million hole scores. Plumbing is not glamorous. But every confident claim later in the book, from "a single round says almost nothing" to "this player is a 14% favourite", is only as good as these pipes.

Learning paths for this chapter

  • ⛳ Golfer: Read the hook, §2.1, §2.7 (what isn't free) and §2.8–§2.10 (the simulator and how to record your own rounds). Skim the code. Do the ⛳ action at the end of §2.10.
  • 📊 Analyst: Everything. Run every script in code/, and read scripts/fetch_espn.py and scripts/build_espn.py alongside §2.3–§2.5.
  • 🏌️ Coach/Fitter: §2.1, §2.7, §2.8 and §2.10. The shot and scorecard templates in §2.10 are what you hand a student who wants to track rounds.
  • 🎰 Betting/DFS: §2.1–§2.6, especially §2.5 (the quirks that silently break outcome data: the wrong winners, the staggered starts and the withdrawals) and the corrected outcome columns. Your models in Parts VI–VII depend on them.

2.1 Three Kinds of Numbers

This book makes a promise that most golf books can't: every number in it comes from one of a few places you can check. There are three main kinds.

1. Real scores. ESPN publishes free JSON for every PGA TOUR event. It holds every player's score on every hole of every round, plus the par and yardage of every hole and, from 2015, per-player tournament statistics such as driving distance, fairways, greens in regulation and putts per green. That covers 1,061 events from the 2004 Mercedes Championships (which ended on 11 January 2004) to The RSM Classic (which ended on 23 November 2026). When the book says "Scottie Scheffler's field-adjusted strokes gained" or "Augusta's 12th played over par", the number was computed from these scores.

2. Simulated shots. ESPN has no shot locations, lies, clubs or wind. The shot-level data that would let us split strokes gained into driving, approach, short game and putting (the PGA TOUR's ShotLink data) is not free. So the book uses a shot simulator, golfkit.shotsim. It is calibrated to published benchmarks, it runs from a fixed seed so you can reproduce every number exactly, and every number it produces is labelled SIMULATED. All amateur data in the book, including all of the cast's rounds, comes from it.

3. Cited reference values and model outputs. Broadie's PGA TOUR strokes-gained baseline, TrackMan's published tour averages, the World Handicap System formulas, and the equipment rules live in data/reference/. Each comes with its source and a confidence tag. Physics numbers come from golfkit's flight and impact models, which are validated against those published tables (Chapter 1 did that validation).

The real-data snapshot is big enough to support serious statistics:

What Count (exact)
Events in the snapshot (all formats) 1,061
Events usable for modelling (individual stroke play, stroke_play_ok) 1,031
Majors (assigned to the calendar year in which they ended) 91
Distinct players 4,221
Player-events (one player in one tournament) 134,632
Round rows / complete 18-hole rounds 421,245 / 417,380
Hole-score rows 7,535,490
Rounds in the field-adjusted strokes-gained model 408,603
Per-player tournament statistics rows (2015–2026) 67,509 rows in 538 events

Those counts come from golfkit.data.inventory(). You will reproduce them in a minute.

🧪 Assumption When this chapter (and every later one) uses the simulator, the golfers' skill parameters are assumptions fitted to published averages. They are not measurements of real people. Where the simulator's demo "member course" needs a Course Rating and Slope, it uses CR 70.8 / Slope 125. Those are values typical of a 6,400-yard member tee, not the rating of a real course. Every simulated number inherits these assumptions, which is why each one carries its seed and the SIMULATED label.

Why insist on this? Because golf statistics are a minefield of plausible numbers with no source. You will meet them all the time: "Tour players make 96% from 3 feet." "The average golfer loses most strokes inside 100 yards." "Amen Corner costs the field a stroke and a half." Some are close, some are wrong, and a few are invented. Later chapters test several of them. That testing only means something if our own numbers can be traced.

💡 Key Insight A number you can't trace is a rumour. Every table in this book can be traced to a script you can run, a seed you can change, or a source you can read.

🔄 Check Your Understanding 1. Which of the three kinds of numbers would you need in order to say "Rory McIlroy gained 1.2 strokes per round on approach shots in 2026"? Can this book give you that number? 2. Why does every simulated number carry a seed?

Answers

  1. That number is strokes gained by category, which needs shot-level data: where each shot started and finished. ESPN doesn't publish that, so the book cannot compute it from real data. A real value would have to come from the PGA TOUR's own published statistics or a paid source (§2.7). The book never presents a simulated category number as a real player's number.
  2. Because a seed makes the randomness repeatable. With the same seed you get exactly the same shots and the same number, so anyone can check the result. With a different seed you see how much the number moves by chance, and that is a lesson in itself (Chapter 14).

2.2 ESPN's Open JSON: What's in the Box

ESPN's website is fed by public JSON endpoints. Nobody has to log in, and the responses are plain text a browser can display. They are unofficial: ESPN doesn't document them for outside use and can change them without notice. Our pipeline uses three kinds of document.

Endpoint family What one document holds Saved as
Scoreboard (site.api.espn.com/apis/site/v2/sports/golf/pga/scoreboard?dates=YYYYMMDD) The week's event(s): every competitor, every round, every hole data/raw/espn/scoreboard/pga_YYYYMMDD.json
Core event document (sports.core.api.espn.com/v2/sports/golf/leagues/pga/events/{id}) Courses with par and yardage per hole, purse, flags data/raw/espn/events/pga_{id}.json
Competitor statistics (…/events/{id}/competitions/{id}/competitors/{player}/statistics) One player's tournament stats: driving distance, accuracy, GIR, putts per GIR, sand saves, scoring counts, earnings gathered per event into data/raw/espn/players/pga_{id}.json

Let's open one. The first script walks through the raw files for the 2026 Masters. It uses nothing but Python's json module, so you can see the data before any library touches it.

# code/01_raw_json_tour.py (excerpt): walk the nesting of one weekly scoreboard
import json
sb = json.loads(SCOREBOARD.read_text(encoding="utf-8"))   # one week's file, parsed into dicts/lists
event = sb["events"][0]                                     # a week can hold several events
comp = event["competitions"][0]                             # golf events have one "competition"
players = comp["competitors"]                               # one entry per player, in ESPN's order
leader = players[0]
for rnd in leader["linescores"]:                            # level 1: rounds
    holes = rnd.get("linescores", [])                       # level 2: holes inside each round
    print(rnd["period"], rnd["value"], len(holes))          # round number, strokes, hole count
for h in leader["linescores"][0]["linescores"]:             # round 1, hole by hole
    rel_txt = h["scoreType"]["displayValue"]                # "E", "-1", "+1", ... relative to par
    rel = 0 if rel_txt == "E" else int(rel_txt)
    par = int(h["value"]) - rel                             # par is not stored; derive it

The output for the first competitor is the champion:

Scoreboard file pga_20260412.json: 611 KB; top-level keys ['leagues', 'season', 'day', 'events', 'provider']
  competitors: 91
First competitor in ESPN order: Rory McIlroy (id 3470, order 1, score -12)
  round 1: value 67 strokes, display  -5, 18 hole records
  round 2: value 65 strokes, display  -7, 18 hole records
  round 3: value 73 strokes, display  +1, 18 hole records
  round 4: value 71 strokes, display  -1, 18 hole records

The structure is a tree: events → competitions → competitors → rounds → holes. Each hole record holds the strokes (value), the hole number (period) and the score relative to par as text (scoreType.displayValue). ESPN doesn't store the par in the hole record at all. We derive it: on McIlroy's first hole, 4 strokes at "E" means par 4, and on the second, 4 strokes at "−1" means par 5. That subtraction, par = strokes − relative, is how the whole snapshot gets its pars. As you'll see in §2.4, it has one ugly edge case.

The core event document holds the course itself:

  course 'Augusta National Golf Club': par 72, 7565 yd, 18 holes
  hole:    1    2    3    4    5    6    7    8    9
  par :    4    5    4    3    4    3    4    5    4
  yds :  445  585  350  240  495  180  450  570  460
  purse field: 22500000.0

So we have two independent sources of par: the course document, and the par derived from every player's hole score. In §2.6 we check that they agree for every hole of the 2026 Masters (they do, with zero mismatches). When they disagree, something is wrong. That is exactly how the book found four events whose ESPN course pars are wrong (§2.5).

The player statistics file holds 26 fields per player. For McIlroy at the 2026 Masters:

  driveDistAvg      330.39
  driveAccuracyPct  55.36
  gir               66.67
  girPoss           72.0
  puttsGirAvg       1.636
  sandSaves         50.0
  birdies           24.0
  bogeys            8.0
  regScore          276.0

These are the "traditional" statistics, and Chapter 10 explains why strokes gained replaced most of them. They exist only from 2015 in our snapshot, and they have their own quirks (§2.5).

⚠️ Common Pitfall: trusting a field because it has a sensible name The round record also carries a statistics block. For the 2026 Masters it includes a timestamp, Thu Apr 09 10:31:00 PDT 2026 for McIlroy's first round, which looks very much like a tee time. The same field appears in a 2016 scoreboard but not in the 2004 or 2010 files we sampled. Our build doesn't parse it, so the processed tables have no tee times, and the book never claims to measure morning/afternoon tee-time effects. If you want to try, start here, but first check how often the field is present and whether it matches published tee sheets (Exercise E.2). A field's name is a hypothesis about its meaning, not a fact.


2.3 The Fetcher: Resumable, Polite, Atomic

scripts/fetch_espn.py downloads everything in four phases, and each phase skips files that are already on disk:

  1. calendar: one request per season, which returns that season's schedule;
  2. scoreboard: one request per tournament week (the date of each event's final day), which returns the hole-by-hole data;
  3. events: one core event document per event id found in the scoreboards;
  4. players: for events from 2015 on, the list of competitors and then one statistics request per competitor.

You run it like this:

python scripts/fetch_espn.py calendar scoreboard events --from 2004 --to 2026
python scripts/fetch_espn.py players --players-from 2015 --workers 4

Three design choices make it robust, and you'll want all three in any scraper-style pipeline you write.

Resumable. Every phase first builds a to-do list of files that don't exist yet. If your laptop sleeps halfway through the 597 player-statistics files, you rerun the same command and it picks up where it stopped. It never downloads a file twice.

Atomic writes. The save function writes to a temporary file and then renames it into place:

# scripts/fetch_espn.py: write-then-rename, so a crash never leaves half a file
def save(path: Path, data) -> None:
    path.parent.mkdir(parents=True, exist_ok=True)   # create data/raw/espn/... if needed
    tmp = path.with_suffix(".tmp")                   # write somewhere harmless first
    tmp.write_text(json.dumps(data), encoding="utf-8")
    tmp.replace(path)                                # the rename is all-or-nothing

Why does that matter? Because the "skip if the file exists" rule is only safe if a file that exists is complete. A crash in the middle of write_text leaves a .tmp file, which the next run ignores, rather than a truncated .json file, which the next run would skip forever.

Polite retries. get_json waits a quarter of a second after every successful request, and it retries failures with exponential backoff: it sleeps 1, 2, 4, 8 and 16 seconds before giving up. The thread pool defaults to four workers. A server that is struggling gets less traffic from us, not more.

# scripts/fetch_espn.py: retries with exponential backoff and a pause between calls
def get_json(url: str, tries: int = 5, pause: float = 0.25):
    for attempt in range(tries):
        try:
            req = urllib.request.Request(url, headers=UA)    # UA = {}: Python's default User-Agent
            with urllib.request.urlopen(req, timeout=45) as r:
                data = json.load(r)
            time.sleep(pause)                                # be gentle between requests
            return data
        except Exception as exc:                             # network hiccup, 5xx, rate limit
            wait = 2 ** attempt                              # 1, 2, 4, 8, 16 seconds
            print(f"  retry {attempt + 1} ({exc}); sleeping {wait}s", file=sys.stderr)
            time.sleep(wait)
    return None                                              # caller skips; rerun picks it up

⚠️ Common Pitfall: the custom User-Agent that gets you blocked A common piece of scraping advice is "always send a descriptive User-Agent header". For these ESPN endpoints, that advice backfires. Requests carrying a custom User-Agent string came back 403 Forbidden, while Python's default urllib User-Agent worked. That is why the script sends an empty header dictionary (UA = {}). This is a practical observation about one service's behaviour, not a trick for getting past anyone's controls. Use these endpoints for personal and educational analysis at a modest request rate, respect any terms ESPN publishes, and stop if you are asked to. If a site tells you it does not want automated access, the right response is to stop, not to disguise your client.

The whole download comes to 1,050 weekly scoreboard files (890 MB), 1,140 event documents (158 MB) and 597 player-statistics files (37 MB), about 1.1 GB of raw JSON. The players phase is by far the slowest, because it makes one request per player per event. The 67,509 statistics rows in the snapshot each cost one request, so let that phase run in the background.

🔍 Why Does This Work? Why fetch the scoreboard by date rather than asking for each event by id? Because the scoreboard is the only document that has every player's hole-by-hole scorecard in one response. A single request per week returns the whole field (91 players at the 2026 Masters, 611 KB). Compare the players phase, where the statistics live one player per document and a 150-player field costs 150 requests. The calendar phase exists only to find the right dates. Requesting a mid-season date (?dates={year}0601) returns that season's whole calendar, so 23 requests give us every tournament week from 2004 to 2026.

🔄 Check Your Understanding 1. The players phase is interrupted after 300 of 597 files. What happens when you rerun it? 2. Why does save write to a .tmp file first? 3. A request fails five times in a row. What does get_json return, and what happens to that file?

Answers

  1. It builds its to-do list from the files that don't exist yet, so it fetches only the remaining 297.
  2. So that a crash can never leave a partial .json file. A partial file would be skipped as "done" on every later run.
  3. It returns None. The caller skips the save, so the file stays missing and the next run tries it again.

2.4 From JSON to Tidy Tables

Nested JSON is a fine format for a web page and a poor one for analysis. You can't ask a tree "what was the field's average on the 12th hole?" without walking every branch. So scripts/build_espn.py flattens the tree into six tidy tables, and scripts/build_player_stats.py adds a seventh.

Tidy data has a precise meaning (the term comes from the statistician Hadley Wickham). Each row is one observation, each column is one variable, and each table holds one kind of observation. For golf, that means one table per level of the tree:

Table One row per… Key columns Rows
events event event_id, name, start_date, end_date, season, major, course_name, purse 1,061
courses event × course × hole event_id, course_name, hole, par, yards (per hole)
players player player_id, name, country 4,221
player_events event × player espn_order, status, position, won (first pass) 134,632
rounds event × player × round score, par, holes_played, complete, par_signature 421,245
holes event × player × round × hole strokes, par 7,535,490
player_stats event × player (2015+) driveDistAvg, driveAccuracyPct, gir, puttsGirAvg, sandSaves, … 67,509

Notice what tidiness buys you. "The field's average on the 12th hole" becomes one line: filter holes to the event and hole, then take the mean of strokes. "Everyone's score in round 3" is a filter on rounds. The keys (event_id, player_id, round, hole) are how tables join back together. A table whose rows are "one player-round" and whose columns are "hole 1, hole 2, … hole 18" (the familiar scorecard layout) is wide. It is great for reading and awkward for computing. We store long, tidy tables, and we pivot to wide only for display (§2.6).

The tables are stored as Parquet files. Parquet is a compressed, column-oriented format that pandas reads very fast. The compression is dramatic (code/01_raw_json_tour.py):

  total raw 1,085 MB -> parquet 8.2 MB (133x smaller)

Most of that shrinkage comes from throwing away what we don't need: broadcast details, logo URLs and repeated athlete records. The rest is Parquet's compression of repetitive columns such as par.

What the build keeps, and what it drops

Not everything in ESPN's PGA TOUR feed is a stroke-play golf tournament. Replaying the build's filters over every raw weekly file (code/02_build_rules.py) gives an exact accounting:

Scanned 1,050 weekly scoreboard files in 16 s
  event records: 1,166
  kept by the build: 1,061
  duplicate records (same event in two weekly files): 26
  distinct event ids: 1,140
Dropped: not final (cancelled or not yet played): 19
Dropped: final, but no competitors listed: 42
Dropped: competitors listed, but no hole-by-hole scores: 18
Dropped: match play or Stableford-format name rule: 0

The 19 events that never finished include 13 from 2020 that ESPN marks STATUS_CANCELED (among them THE PLAYERS Championship and The Open, in the pandemic year) and two 2026 events still STATUS_SCHEDULED when the snapshot was taken. The 42 "final but empty" records are mostly match play and team events: Ryder Cups, Presidents Cups, the WGC Match Play, and most Zurich Classics. ESPN lists no individual stroke-play competitors for them. The 18 with competitors but no hole scores include the three Stableford-format Internationals of 2004–2006 and the more recent Ryder and Presidents Cups. The build also has an explicit name rule that skips "match play" and "International" events, but it removed nothing. By the time a record reaches that rule, the earlier checks have already caught every such event. Keep a belt-and-braces rule like that in place, and count what it catches.

🧩 Productive Struggle Before reading on, think about this. ESPN reports each hole's score relative to par as text ("E", "−1", "+2"), and the build derives par as strokes minus that number. What could go wrong with a score of 8 on a par 4? Write down your guess, then read the next paragraph.

The "OTHER" hole: when ESPN stops counting

Here is the edge case. Counting every hole record in the kept events by its relative-to-par code (code/02_build_rules.py):

Hole records in kept events, by ESPN's relative-to-par code (scoreType.displayValue):
  numeric (E, -1, +2, ...): 7,563,050
  OTHER: 3,466
  (blank): 2,310
  strokes on holes coded 'OTHER': {0: 22, 7: 599, 8: 1801, 9: 803, 10: 170, 11: 44, 12: 17, 13: 7, 14: 2, 16: 1}

For quadruple bogey or worse, ESPN doesn't write "+4". It writes the word OTHER. An 8 on a par 4 arrives as "8 strokes, OTHER", and from that record alone you cannot tell whether the hole was a par 4 or a par 3. The first version of the build skipped those holes, and it skipped holes whose tag implied an impossible par in the same way. That made the round look incomplete (17 holes), which made the player look like a withdrawal, which is one more route to the kind of error in this chapter's opening.

The current build treats every hole whose tag can't give a par of 3, 4 or 5 as "par unknown". That covers the OTHER holes and the impossible tags, such as the 2023 Open's 3 tagged "+2" (Case Study 1). It reads the missing par from the other players' scorecards. Where at least 85% of the players in that event and round agree on the hole's par, it takes that consensus. Otherwise it takes the par sequence that agrees with every hole this player does have a usable code for, which matters at multi-course pro-ams, where two courses are in play the same day. The same consensus corrects 443 minority pars that a mislabelled tag had put out of line with everyone else on the hole. There were 3,466 OTHER records; 22 of them have zero strokes and are dropped as empty records. That leaves 3,444 real blow-up holes, mostly at 8 strokes (1,801 of them). Counting the impossible tags as well, the build's run log reports 12,946 unknown pars resolved and 134 unresolved. The fixes came in two passes. The first resolved only the OTHER holes, and it turned 3,196 rounds that had looked incomplete into complete 18-hole rounds. The second, for impossible tags, took the count of complete rounds from 416,529 to 417,380. The strokes-gained model now holds 408,603 rounds. Even the headline spread of tour scores moved: the within-player round SD, a number you'll meet throughout Part II, went from 2.723 strokes before the first fix to 2.756 in the final build. Adding back a few thousand disasters makes golf look slightly more random, which is the honest answer. These are real disasters on real holes, and the strokes-gained model needs them. A model that drops a player's 9 on a par 5 makes him look better than he was.

💡 Key Insight Missing data is rarely random. The holes ESPN encodes as OTHER are precisely the worst holes. Dropping them would bias every scoring average downward, and the bias would be largest for the players and courses where blow-ups are common.

The course signature

One more derived column carries a lot of weight: par_signature. For each complete round, the build hashes the hole-by-hole sequence of pars, so "4,5,4,3,4,3,4,5,4,4,4,3,5,4,5,3,4,4" becomes a short code such as 0daa3644. Two rounds with the same signature were (almost certainly) played on the same course. This is how the pipeline detects multi-course pro-ams, where the field is split across two or three courses for the early rounds, even when ESPN's event document lists the wrong number of courses. As §2.5 shows, comparing players across different courses is one of the easiest ways to get strokes gained wrong.

🔄 Check Your Understanding 1. Why is a long holes table (one row per hole score) better for analysis than a wide scorecard (one row per round, 18 hole columns)? 2. A player's scorecard shows 17 numeric holes and one "9 strokes, OTHER" on hole 14. What does the build do with hole 14? 3. Why can't the par signature tell two courses apart if they have identical par sequences?

Answers

  1. Each question becomes a filter plus an aggregation on one column (for example, the mean of strokes where hole == 12), and the same code works for 9-hole, 18-hole and 3-course events. Wide tables need a different column for every hole and break when the number of holes changes.
  2. It marks hole 14's par as unknown and reads it from the other players: the consensus par on hole 14 in that event and round or, at a multi-course event, the par sequence consistent with his 17 known pars. It keeps the 9 as a real score.
  3. The signature is computed only from pars, so two courses with the same pars on every hole produce the same hash. This happens once in the snapshot: the 2005 Bob Hope, with 5 courses but only 4 signatures. Appendix B records the case.

2.5 The Quirks, Counted

Every real dataset has quirks. What separates analysis from guesswork is knowing them by count, so that you know how big each problem is and whether it touches your question. Figure 2.1 lists every quirk the book's toolkit handles, with its exact count in the current snapshot.

Figure 2.1 — The snapshot's quirks, counted

📊 Figure (described): A horizontal bar chart on a logarithmic count scale. Three orange bars are player-level rows: 4,741 player-events that the build labels WD/DQ, 3,865 incomplete round rows and 1,199 player-events that golfkit relabels. Blue bars are whole events: 107 multi-course events, 93 events whose ESPN season differs from the calendar year, 64 opposite-field events, 17 non-stroke events, 9 Q-School events, 8 exhibitions, 8 team events, 6 staggered-start TOUR Championships, 4 events with wrong ESPN hole pars and 3 events failing the quality screen. The log scale makes all of them readable on one chart. The wrong-winner count is now zero, so it has no bar (see quirk 2).

Take them one at a time.

1. Withdrawals that weren't (4,741 → 3,542). This is the quirk from the opening. The build labels a player "WD/DQ" whenever one of his rounds is incomplete in its tables. It does so for 4,741 player-events in the final build. golfkit's data.player_events() adds corrected columns that check every round's score (ESPN's round total survives even when the hole-by-hole scorecard doesn't), ESPN's leaderboard order and the inferred cut rule. Of the 4,741, it relabels 1,199 as finishers, missed cuts or MDF players ("made cut, did not finish": the second cut used on tour from 2008 to 2019). Most of them, 1,071, are MDF players. That leaves 3,542 genuine withdrawals and disqualifications. Figure 2.2 shows the gap by year.

Figure 2.2 — The build's WD/DQ label vs genuine withdrawals

📊 Figure (described): Paired bars for each calendar year from 2004 to 2026. Orange bars count player-events labelled WD/DQ by the build and blue bars count genuine withdrawals after correction. In the early years the two are close (2004: 143 vs 139). From 2008 to 2019 the orange bars are much taller, mainly because MDF players were labelled WD/DQ (2014: 218 vs 83, with 130 of the difference MDF). From 2020 on the two are close again (2023: 234 vs 226; 2024: 247 vs 230). Before the label fix, 2023 and 2024 showed a second gap, caused by rounds with unreadable hole tags such as the 2023 Open's. 2026 is low and close (44 vs 41).

2. Wrong winners (4 events in the first pass, none now). In the first-pass build, the won flag pointed at the wrong player in four events, because the true winner's scorecard looked incomplete. Those were the 2022 Sentry Tournament of Champions (the build said Jon Rahm; the winner was Cameron Smith), the 2022 Open (the build said Cameron Young; Cameron Smith), the 2023 Open (Shubhankar Sharma; Brian Harman) and the 2024 ISCO Championship (Matt NeSmith; Harry Hall). Four out of 1,061 sounds tiny. But a betting model evaluated on "did the favourite win?" would have marked a correct forecast as wrong in two Opens. Once the label fixes completed those scorecards, the raw won agreed with won_fixed everywhere except the 2026 Zurich Classic, a team event that no individual model uses. Use won_fixed anyway. It is the column built to be right, and the next data refresh could bring a new quirk.

⚠️ Common Pitfall: using the raw outcome columns player_events.parquet still contains the build's first-pass status, position, won and cut_after_round. They are kept so you can see the problem, not so you can use them. For any finish, cut or win statistic, read the corrected status_fixed, position_fixed, won_fixed, made_cut_fixed and total_fixed through golfkit.data.player_events(). For cut rules, use golfkit.data.infer_cuts(). In Chapter 34's walk-forward test, the outcome columns are the difference between a calibrated tournament model and one that under-predicts top-10 finishes.

3. Two calendars (93 events). ESPN assigns each event to a PGA TOUR season, and from late 2013 the TOUR's season started in the autumn. So an event played in October 2013 belongs to "season 2014". In 93 events the season differs from the calendar year of the final round. The effects are not subtle. ESPN's season 2013 contains only 38 events (its autumn events were pushed into 2014), and season 2023 contains 58 (it absorbed the autumn of 2022 when the TOUR moved back to a calendar-year season). The majors scramble too: season 2020 contains 1 major and season 2021 contains 6, because the November 2020 Masters falls in season 2021. By calendar year, 2020 has 3 majors (there was no Open in 2020) and 2021 has 4. This book always uses the calendar year of the event's end date (year).

Figure 2.3 — ESPN's season vs the calendar year

📊 Figure (described): Paired bars of events per year from 2004 to 2026, blue for the calendar year and orange for ESPN's season. They match exactly through 2012. Season 2013 drops to 38 events against 45 calendar-year events, and season 2023 jumps to 58 against 47. In between, small differences appear (2019: 44 by season vs 47 by year; 2020: 37 vs 35). An annotation marks each of the two large jumps.

4. Multi-course pro-ams (107 events). At events such as the AT&T Pebble Beach Pro-Am, The American Express and the Farmers Insurance Open, the field is split across two or three courses for the early rounds. Comparing everyone with the round average then mixes up course difficulty and player skill. The 2026 Farmers Insurance Open shows how large the effect is (code/05_multicourse_and_staggered.py).

  Torrey Pines (North Course): par 72, 7,258 yd; pars 443454435543443454
  Torrey Pines (South Course): par 72, 7,765 yd; pars 443445435434544345
Rounds 1–2 mean score by course: {'Torrey Pines (North Course)': 69.36, 'Torrey Pines (South Course)': 72.44}; gap 3.08
Mean raw SG per round by course, naive (event-round) vs course-round grouping:
                             naive_sg  course_round_sg
Torrey Pines (North Course)      1.54              0.0
Torrey Pines (South Course)     -1.54              0.0

Both courses are par 72, but the South Course is 507 yards longer, and it played 3.08 strokes harder per round in rounds 1–2. Each player played one round on each course, so over two rounds the effect evens out. Within a single round, though, comparing a South Course 71 with the whole round's average makes it look like a bad round, when it was about a stroke and a half better than the South Course field. Grouping by course-round (event, round, course signature) removes the artefact. It is the canonical grouping for every strokes-gained number in this book (Chapter 12 builds on it).

Figure 2.4 — The 2026 Farmers Insurance Open: one field, two courses

📊 Figure (described): Two step histograms of round scores from rounds 1 and 2, each with 146 rounds. Blue shows the North Course, centred near 69 (dashed mean line at 69.36). Orange shows the South Course, centred near 72 (mean line at 72.44). The two distributions overlap, but the South Course histogram is shifted about three strokes to the right.

5. Staggered-start TOUR Championships (6 events, 2019–2024). From 2019 to 2024 the FedExCup finale started players at different scores ("Starting Strokes") according to their season-long ranking. So the lowest 72-hole score did not necessarily win:

  2019 Tour Championship: winner Rory McIlroy (267 strokes, stroke rank 1); lowest total Rory McIlroy (267)
  2020 Tour Championship: winner Dustin Johnson (269 strokes, stroke rank 3); lowest total Xander Schauffele (265)
  2021 TOUR Championship: winner Patrick Cantlay (269 strokes, stroke rank 4); lowest total Jon Rahm (266)
  2022 TOUR Championship: winner Rory McIlroy (263 strokes, stroke rank 1); lowest total Rory McIlroy (263)
  2023 TOUR Championship: winner Viktor Hovland (261 strokes, stroke rank 1); lowest total Viktor Hovland (261)
  2024 TOUR Championship: winner Scottie Scheffler (264 strokes, stroke rank 3); lowest total Collin Morikawa (262)

In 2020, 24 of the 30 finishers have a stroke rank that differs from the official order. golfkit flags these events (staggered_start) by noticing that ESPN's leaderboard order disagrees with stroke totals in more than 10% of adjacent pairs, and position_fixed follows ESPN's order there. For strokes gained this quirk doesn't matter, because each round's score is still a real round. For "who won?", it matters a great deal.

6. Stableford and match play (17 non-stroke events, plus the dropped ones). Besides the match-play and Stableford events dropped at build time (§2.4), the Barracuda Championship was played under a modified Stableford points system from 2021 to 2025, and ESPN's "round score" there is points, not strokes. golfkit flags those 5, along with 8 The Match-style exhibitions and 4 events with no hole data at all, as is_nonstroke, and excludes them from every model.

7. Team events (8), exhibitions (8) and Q-School (9). The Zurich Classic of New Orleans has been a two-man team event since 2017. Its 2022, 2023, 2025 and 2026 editions are in the snapshot as team entries, and its 2017–2021 and 2024 editions were dropped at build time. There are also team exhibitions and nine qualifying tournaments with non-tour fields. All are excluded by stroke_play_ok.

8. Shortened events (11) and quality failures (3). Weather (and occasionally ESPN's data) leaves 11 usable events with fewer than four rounds, from the 2004 PGA Championship (two rounds in ESPN's data) to the 2026 Butterfield Bermuda Championship (three). Their rounds are real and stay in the strokes-gained model, but tournament-outcome studies use four-round events only. Separately, 3 usable events fail a completeness screen (quality_ok: at least 90% complete round rows and at most 25% WD/DQ labels): the 2004 PGA Championship, the 2005 Shell Houston Open and the 2019 RBC Canadian Open. Before the label fix the list was longer, and the 2023 Open was on it; Case Study 1 rebuilds that event.

9. Wrong pars (4 events). For the 2004–2006 Bay Hill Invitationals and the 2005 Booz Allen Classic, ESPN's hole pars don't add up to the course par. The build flags them (bad_par), and golfkit marks them par_ok False. They stay in stroke_play_ok and in the strokes-gained model, because strokes gained compares scores with other scores and never uses par. But every to-par, hole-scoring or score-type analysis must leave them out, and data.hole_scoring does that automatically.

10. Player statistics: from 2015 only, and zero means missing. ESPN's per-player tournament statistics exist for 538 events from 2015 to 2026. Where ESPN lacks a statistic, it reports 0 rather than leaving it blank. A driving distance of 0 yards is obviously "missing", but an average of zeros and real values is silently wrong. In 6,825 of the 67,509 rows (10.1%), driveDistAvg is 0 or missing. There is also a subtler trap: in some events, especially most of 2015 and many in 2023, the statistics cover only three of the four rounds (girPoss = 54 instead of 72). Chapter 10 handles both problems.

Figure 2.5 — ESPN per-player statistics exist from 2015 only

📊 Figure (described): Stacked bars of player-statistics rows per calendar year from 2015 to 2026, about 5,100–6,000 rows per year, except 2020 at 4,123. The blue segment counts rows with a real driving distance. The orange top segment counts rows where ESPN reports 0, which should be treated as missing. It ranges from 152 rows (2020) to 726 (2019). No bars appear before 2015.

11. Pars that disagree with the course (fixed in the final build). Before the label fix, the cross-source check from §2.6, run over the whole snapshot, found 1,282 hole rows spread over 49 events and 231 players where the par derived from ESPN's relative-to-par code was 6. In 1,280 of them the course document said the hole was a par 4. One example sat in the 2025 Masters: four holes on Matthieu Pavon's scorecard where a 5 was coded as "one under". The strokes were right and only the code was off, so round totals and strokes gained were unaffected. But any hole-by-par table built straight from derived pars contained phantom par 6s. The consensus-par rule (§2.4) now corrects them, and the same check in code/09_exercise_checks.py finds 0 par-6 rows. The lesson stands: check derived pars against the course document, because the next ESPN glitch may be one no rule anticipated. Exercise C.1 asks you to run the check.

⚠️ Common Pitfall: what the snapshot doesn't contain The snapshot is PGA TOUR only (plus the majors, which ESPN lists on the TOUR's schedule). LIV Golf, DP World Tour, Korn Ferry Tour and LPGA hole-by-hole data are not in it. A player who moved to LIV is rated only on his PGA TOUR and major rounds. ESPN also gives no shot locations, lies, clubs, wind or (in our processed tables) tee times. And 35 events have no usable course document, so 360 event-holes have no yardage: any yardage-based analysis must drop or fill them, and say which. Every later chapter states these limits when they matter.

🔄 Check Your Understanding 1. You are counting majors won per season and find that "season 2021" has six. What happened, and which column should you use? 2. Why would comparing a player's round with the whole round's average be wrong on the first day of the Farmers Insurance Open but fine on the final day? 3. Your model says the favourite won the 2023 Open. The raw won column says he didn't. Which do you believe, and why?

Answers

  1. ESPN's season 2021 includes the November 2020 Masters plus the four 2021 majors. Use year, the calendar year of the end date.
  2. On days 1–2 the field is split across two courses that differ by about three strokes, so the round average mixes the two. By the final round everyone plays the South Course, so the round average is a fair comparison.
  3. Believe won_fixed, which names Brian Harman. In the first-pass build the raw flag was wrong for that event, because the winner's hole-by-hole scorecard looked incomplete. In the final build the two agree, but won_fixed is the column built to be right.

2.6 pandas in Golf Terms: The 2026 Masters, End to End

Chapter 1 got Python running and plotted one trajectory (and Appendix A covers more Python). Now we need the library that does most of the book's work: pandas, which holds tables in memory as DataFrames and lets you filter, group, join and reshape them. We'll learn it the practical way, by taking one real tournament from raw tables to a leaderboard, a hole-difficulty chart and a scorecard. Everything below is in code/04_masters_2026_end_to_end.py.

You don't load the parquet files by hand. golfkit.data does it, and it adds the derived flags (year, multicourse, stroke_play_ok, the corrected outcomes and the rest):

# code/04_masters_2026_end_to_end.py (excerpt 1): find an event and read its leaderboard
from golfkit import data
ev = data.event_lookup("Masters", year=2026)          # name substring + calendar year -> matching events
eid = ev["event_id"].iloc[0]                           # "401811941"
names = data.players()[["player_id", "name"]]          # id -> name lookup table
pe = data.player_events(event_ids=[eid])               # one row per entrant, with corrected columns
pe = pe.merge(names, on="player_id")                   # JOIN: attach each player's name
pe["to_par"] = pe["total_fixed"] - 72 * 4              # a new column computed row by row
board = (pe[pe["status_fixed"] == "finished"]          # FILTER: boolean mask keeps finishers
         .sort_values(["position_fixed", "espn_order"])
         [["position_fixed", "name", "total_fixed", "to_par"]])
print(board.head(10).to_string(index=False))
 position_fixed              name  total_fixed  to_par
            1.0      Rory McIlroy        276.0   -12.0
            2.0 Scottie Scheffler        277.0   -11.0
            3.0    Tyrrell Hatton        278.0   -10.0
            3.0    Russell Henley        278.0   -10.0
            3.0       Justin Rose        278.0   -10.0
            3.0     Cameron Young        278.0   -10.0
            7.0   Collin Morikawa        279.0    -9.0
            7.0         Sam Burns        279.0    -9.0
            9.0          Max Homa        280.0    -8.0
            9.0 Xander Schauffele        280.0    -8.0

Four ideas in nine lines. A filter (pe[mask]) keeps rows where a condition is true. A merge joins two tables on a shared key, which is how a player_id becomes a name. A new column is computed across all rows at once, with no loop. And sort_values plus column selection shapes the result. Of the 91 entrants, 54 finished and 37 missed the cut. The inferred cut line was 148 for 36 holes, and for this event the raw and corrected status labels agree for all 91 players. (The Masters has complete ESPN scorecards. The 2023 Open didn't, until the label fix in §2.4.)

groupby: the workhorse

The most useful pandas verb for golf is groupby: split the rows into groups, compute something for each group, and combine the results. "Field scoring average by round" is one line:

# excerpt 2: split rounds by round number, summarise each group
rd = data.rounds(event_ids=[eid])                    # complete 18-hole rounds only (the default)
by_round = rd.groupby("round")["score"].agg(["count", "mean", "std", "min", "max"])
       count   mean   std   min   max
round
1         91  74.65  3.64  67.0  84.0
2         91  72.85  3.44  65.0  81.0
3         54  70.63  2.76  65.0  78.0
4         54  72.09  3.74  66.0  80.0

Round 1 played 4.02 strokes harder than round 3 (74.65 vs 70.63). Part of that is the course and the conditions. Part of it is that round 3's field is the 54 who made the cut, which is a better group of golfers. This is exactly the confusion of course difficulty with field strength that the field-adjusted strokes-gained model in Chapter 12 untangles. Raw averages are a starting point, never an answer.

merge with validation

Hole scores and the course document both claim to know each hole's par. A merge lets us check:

# excerpt 3: join hole scores to the course table, and make pandas check the join's shape
ho = data.holes(event_ids=[eid])                                  # 5,220 rows: player x round x hole
crs = data.courses(event_ids=[eid])[["hole", "par", "yards"]]     # 18 rows: one per hole
merged = ho.merge(crs, on="hole", how="left",
                  suffixes=("", "_course"),                       # par vs par_course
                  validate="many_to_one")                         # raise if crs had duplicate holes
mismatch = (merged["par"] != merged["par_course"]).sum()          # 0 for the 2026 Masters
chk = ho.groupby(["player_id", "round"])["strokes"].agg(["sum", "size"]).reset_index()
chk = chk.merge(rd[["player_id", "round", "score"]], on=["player_id", "round"])
bad = (chk["sum"] != chk["score"]).sum()                          # hole strokes must add to the round
Hole rows: 5,220; par from scores vs par from the course document: 0 mismatches
Complete rounds checked: 290; hole sum != round score: 0; rounds without 18 holes: 0

validate="many_to_one" is a small habit that will save you a bad afternoon. If the course table ever had two rows for hole 7 (a multi-course event, say), pandas would raise an error instead of silently doubling those hole scores. The two checks after the merge, par against par and hole sum against round score, are the same cross-source checks that found the wrong-par events and the incomplete scorecards in §2.5. Run them on every event you study.

Hole difficulty

data.hole_scoring is a groupby over hole scores, with the score categories precomputed:

 hole  par  yards   n   avg  to_par  p_birdie  p_par  p_bogey  p_double_plus
    5    4  495.0 290 4.297   0.297     0.052  0.614    0.321          0.014
   11    4  520.0 290 4.293   0.293     0.059  0.641    0.252          0.048
   17    4  450.0 290 4.238   0.238     0.076  0.648    0.238          0.038
  ...
   13    5  545.0 290 4.762  -0.238     0.379  0.462    0.097          0.038
    2    5  585.0 290 4.707  -0.293     0.383  0.510    0.059          0.031
    8    5  570.0 290 4.624  -0.376     0.376  0.548    0.041          0.007

Figure 2.6 — 2026 Masters: how each hole played

📊 Figure (described): Eighteen vertical bars showing each hole's field average relative to par at the 2026 Masters, with the par and yardage printed under each hole number. Orange bars (over par) dominate. The 5th (+0.30), 11th (+0.29), 17th (+0.24) and 4th (+0.22) are the tallest. The four par 5s are blue and below zero: the 8th (−0.38), 2nd (−0.29), 13th (−0.24) and 15th (−0.14). The 3rd (−0.10) and 16th (−0.05) are slightly under par, and the 9th and 14th sit at par.

The pattern is the one Chapter 16 explores in depth. Averaged over all 290 rounds, the par 5s played 0.263 strokes under par, while the par 4s played 0.145 over and the par 3s 0.115 over. The par-5 scoring average is where tour players separate themselves from par. Figure 2.7 shows the same holes as a score mix, the share of eagles, birdies, pars, bogeys and doubles, which is a richer description than the average alone.

Figure 2.7 — 2026 Masters: the score mix on every hole

📊 Figure (described): Stacked 100% bars, one per hole. From the bottom up: eagles or better (purple, at most 2.8% of scores on any hole, on the 8th, and visible mainly on the par 5s), birdies (blue), pars (light grey, the largest segment on every hole at roughly 46–67%), bogeys (orange) and doubles or worse (red). The par 5s (holes 2, 8, 13 and 15) have the largest birdie segments, about a third of all scores, and very small bogey segments. The 5th and 11th have the largest bogey segments. The 12th, a 155-yard par 3, has the largest double-or-worse segment of any hole (5.5%).

📋 Play the Shot: the 12th at Augusta, in numbers You're on the 12th tee at the 2026 Masters, 155 yards. In that week's 290 rounds the field made birdie 14.1% of the time, par 63.8%, bogey 16.6% and double or worse 5.5%, the highest double-or-worse rate on the course. Compare the 5th, a 495-yard par 4 that was harder on average (+0.297 vs +0.152) but produced doubles only 1.4% of the time. The 12th's danger is in its tail, not its average. What does that mean for strategy? On a hole whose cost comes from rare disasters, the play is the one that removes the disaster (the safe side of the green), even if it lowers your birdie chance. On a hole whose cost is a steady leak of bogeys, the fix is just a better average shot. Chapter 18 and Chapter 20 turn this into a decision rule. For now, notice that the score distribution, not just the mean, tells you which kind of hole you're facing.

Reshape: one player's scorecard

Long tables are for computing. For reading, golfers want a scorecard: one row per round, 18 hole columns, then out, in and total. That is a pivot:

# excerpt 4: long hole scores -> wide scorecard for one player
pid = data.player_id("Rory McIlroy")                      # ESPN id "3470"
card = (ho[ho["player_id"] == pid]
        .pivot_table(index="round", columns="hole", values="strokes", aggfunc="sum"))
card["out"] = card[list(range(1, 10))].sum(axis=1)        # holes 1-9
card["in"] = card[list(range(10, 19))].sum(axis=1)        # holes 10-18
card["total"] = card["out"] + card["in"]
hole   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  out  in  total
round
1      4  4  5  3  4  3  4  4  3   4   4   3   4   3   4   3   4   4   34  33     67
2      4  4  3  2  5  3  4  5  4   5   4   2   4   4   4   2   3   3   34  31     65
3      5  5  3  3  4  3  4  5  4   3   6   4   5   3   4   3   5   4   36  37     73
4      4  5  3  5  4  4  3  4  4   4   4   2   4   4   5   3   4   5   36  35     71

Twenty-four birdies or better and ten bogeys or worse. Subtracting his average from the field average hole by hole, and multiplying by four rounds, tells you where he won it. He beat the field by 2.42 strokes on the 15th, 2.05 on the 13th and 2.04 on the 14th. He lost the most to the field on the 11th, where he was 0.83 strokes worse over the week (that 6 in round 3). Treat this as a teaser of hole-level strokes gained, not a result: one player, four rounds, and raw comparisons with a field average that hasn't been adjusted for anything. Chapter 10 does it properly.

Figure 2.8 — 2026 Masters: the top six, round by round

📊 Figure (described): Cumulative score to par after each round for the six players who finished in the top three places, with the y-axis inverted so that lower scores sit higher. McIlroy (blue) leads after round 1 at −5 and after round 2 at −12, drops to −11 after round 3 and finishes at −12. Scheffler (orange) is −2, then level par after round 2, then −7, and finishes at −11. The four players tied for third (grey) converge at −10. Cameron Young's grey line reaches −11 after round 3, level with McIlroy, before finishing at −10.

🔄 Check Your Understanding 1. Write, in words, the pandas steps to find the 2026 Masters field's scoring average on the par 3s. 2. Why does round 3 at the 2026 Masters have a lower field average than round 1, even if the course played exactly the same? 3. What does validate="many_to_one" protect you from?

Answers

  1. Load the hole scores for the event, filter to rows where par == 3, take the mean of strokes (0.115 over par in that week's data), or group by par to get all three types at once.
  2. After the cut, only the best 54 players remain, so the field is stronger. Field strength and course difficulty are mixed together in raw averages.
  3. From a "right" table that unexpectedly has duplicate keys. Without the check, each duplicate silently multiplies the matching rows on the left.

2.7 What Isn't Free, and Why

The ESPN snapshot is wonderful for scores. It can't tell you how a score was made. To split a round into driving, approach, short game and putting, you need to know where every shot started and finished. That is shot-level data, and on the PGA TOUR it comes from one system.

ShotLink. The PGA TOUR's ShotLink system records the start and end position of every shot at TOUR events. It was first used around 2001 (sources differ on whether it reached every event before 2003; strokes_gained_history_and_findings.md, MED confidence). The research data begin in 2003 (Broadie 2012, HIGH), and the four majors are not included, because the majors are run by other organisations. Broadie's PGA TOUR baseline, the table of expected strokes from every lie and distance that this book uses throughout Part II, was built from ShotLink data from 2003 to 2010: "over eight million shots" (broadie_pga_baseline.md, HIGH). ShotLink is the TOUR's own data. The raw shot records are not published for free download.

What is public, and from whom:

Source What you get Cost / access How this book uses it
ESPN JSON (unofficial) Hole scores, course par/yardage, tournament stats from 2015 Free; undocumented; may change All real-score analysis
pgatour.com stats pages Official season statistics, including strokes gained by category (SG: Putting since May 2011; Tee-to-Green and Total from 2014; Off-the-Tee / Approach / Around-the-Green since 2016) Free to view on the website; use is governed by the site's terms Pointed to for real category values; never scraped for this book
ShotLink Intelligence The TOUR's program for making ShotLink data available to academic researchers By application, on the TOUR's terms Recommended to readers doing academic research
DataGolf Player ratings, strokes-gained data and predictions, with public methodology write-ups A commercial subscription service; programmatic (API) access is a paid feature Methodology posts cited; no paid data used
Shot-tracking apps (Arccos, Shot Scope and others) Your own shots, if you track them You own your data; export options vary by product The yardbook schema (§2.10) is built for these exports

(The dates in the pgatour.com row come from strokes_gained_history_and_findings.md: SG: Putting is HIGH confidence, and the 2014 and 2016 dates are MED.)

Why isn't more of it free? Shot tracking at tour scale is expensive: every shot, every hole, every round, every week. The data is valuable to broadcasters, betting operators and the TOUR's partners. Pricing and licensing it is a legitimate business decision, the same one every sports league makes. The ethical path for this book is clear. We use what is openly published, we simulate what isn't and label it, and we tell you exactly where to get the real thing.

⚠️ Common Pitfall: app strokes gained is not tour strokes gained Shot-tracking apps report strokes gained against their baseline, and the baselines differ. Arccos's default benchmark is a scratch golfer, and Shot Scope counts any shot from more than 50 yards as "approach" (amateur_handicap_baselines.md, MED). Their user populations are also self-selected: golfers who buy shot trackers skew more engaged than golfers in general. A "−2.1 approach" in one app is not comparable with a "−2.1 approach" in another, or with a PGA TOUR number. Chapter 15 shows how to choose a baseline that fits your level.

📋 Play the Shot: the question you can and can't answer A friend asks: "Is Scottie Scheffler better at approach shots or at putting?" With this book's free data you can say a great deal about how good he is overall. His field-adjusted strokes gained per round led the TOUR every calendar year from 2023 to 2026 (Chapter 10 has the numbers). You cannot split that total into approach and putting from ESPN data. The honest answer is: "Here's his total; the category split is on pgatour.com's strokes-gained pages, which use ShotLink." Saying "probably approach" from a hunch is exactly what this book refuses to do.

🔄 Check Your Understanding 1. Which public source would you cite for a real PGA TOUR player's SG: Approach in 2026? 2. Why can't Broadie's PGA TOUR baseline tell you anything about how the majors play?

Answers

  1. The PGA TOUR's own published statistics (pgatour.com), which come from ShotLink. A paid service such as DataGolf also reports category strokes gained.
  2. ShotLink's research data exclude the four majors, so the baseline was built only from regular TOUR events.

2.8 The Simulator: Honest Shot Data

So we have real scores but no real shots. Parts II–V of this book are about shots: strokes gained by category, dispersion, aim points, practice plans. There are three ways to proceed.

  1. Invent numbers. "A 15-handicapper loses 1.6 strokes a round on approach." Many golf articles do this. This book never will.
  2. Use only aggregates someone else published. That is honest but limited. You can't compute a dispersion ellipse from a published average, and you can't test a strategy on it.
  3. Simulate shots from a model calibrated to the published aggregates, label every output, and give the reader the code and the seeds. That is what golfkit.shotsim does.

What the simulator models

A Golfer in golfkit.shotsim is a set of skill parameters: how far each club goes, how widely each shot scatters (a lateral angle and a distance percentage that grow with shot length, over a short-game "feel" floor), how often a shot is mishit or hooked or sliced badly, how the lie changes all of that, and a putting model of start-line error and pace error. A Hole is a flat, windless map with a fairway, rough, trees, bunkers, water and out of bounds. Play a hole and the golfer picks an aim and a club, the model draws the outcome from the golfer's error distributions, the ball's new position is classified into a lie, and so on until the ball is holed. Water costs a penalty stroke and a drop at the last dry point on the line back toward the start; out of bounds costs a stroke and a replay.

🧪 Assumption Every one of those parameters is an assumption. The tour preset's club distances are TrackMan's published PGA TOUR carries (HIGH) plus an assumed roll. The amateur presets are smooth curves in handicap, fitted so that their outputs match Broadie's 2008 amateur data (HIGH), Shot Scope's by-handicap averages (MED), and the requirement that 20 simulated rounds on the member course produce a WHS Handicap Index equal to the preset's handicap. None of this is a measurement of any real golfer.

How well is it calibrated?

The key test is whether the simulated tour golfer reproduces Broadie's PGA TOUR baseline. To check it, simulate millions of shots, compute the average strokes to hole out from each lie and distance bucket (the same way the baseline was built from ShotLink), and compare. The toolkit's full check uses 1,339,145 simulated shots (SIMULATED, seed 1) over 187 cells. Its headline results (the full tables are in Appendix B, and Chapter 12 goes into the detail):

Measure Value
RMSE over the main playing ranges (121 cells) 0.050 strokes
RMSE weighted by where tour shots are actually played (weights from 400 simulated tour rounds, seed 21) 0.029 strokes
RMSE over all 187 cells, including 500–600-yard fairway bunkers nobody plays from 0.108 strokes
Main-range cells within ±0.10 of Broadie 111 of 120 (112 of 121 under a slightly different range filter; one boundary cell differs)
Tour preset's scoring on the 7,200-yard demo course (1,000 rounds, seed 5) 71.47 (95% CI 71.29–71.64); Broadie's tee column predicts 71.72 for this routing

You can rebuild a slice of that check yourself in under a second with public functions (code/07_simulator_calibration.py). It holes out 2,000 balls from each of 31 starting points and compares them with Broadie's values.

# code/07_simulator_calibration.py (excerpt): one calibration cell
from golfkit import baselines, shotsim
tour = shotsim.Golfer.tour()                          # the PGA TOUR-average preset
pga = baselines.Baseline.pga()                        # Broadie's published baseline (HIGH)
shots = shotsim.simulate_from(tour, "fairway", 150,   # 2,000 balls from 150 yd in the fairway
                              n=2000, seed=106)
per_ball = shots.groupby("round_id").size() \
         + shots.groupby("round_id")["penalty"].sum() # swings + penalty strokes, per ball
print(per_ball.mean(), pga.expected("fairway", 150))  # simulated vs published
fairway       150   yd   106      2.976 0.012    2.943  0.033
  fairway  RMSE 0.034, max |diff| 0.054
  rough    RMSE 0.047, max |diff| 0.112
  green    RMSE 0.007, max |diff| 0.016
  all      RMSE 0.035 over 31 cells

Figure 2.9 — The simulator's tour golfer vs Broadie's baseline

📊 Figure (described): Two panels. The left panel shows expected strokes to hole out (y, from 2.4 to 3.8) against distance (x, 20–250 yards). Solid lines are Broadie's published values for the fairway (blue) and the rough (orange), and hollow circles with tiny 95% error bars are the simulated tour preset at the same distances. The circles sit on or within about 0.05 strokes of the lines everywhere except rough from 250 yards, where the simulation is 0.11 too hard. The right panel shows expected putts against putt length (3–60 feet). The simulated points lie almost exactly on Broadie's green curve, rising from 1.05 at 3 feet to 2.2 at 60 feet.

That is good agreement, but be precise about what it proves. It shows the simulated tour golfer behaves like the 2003–2010 PGA TOUR average that Broadie measured. It does not show that it behaves like today's tour, and it says nothing direct about amateurs. For amateurs, the calibration targets are Broadie's 2008 Golfmetrics groups and Shot Scope's averages, and the main constraint is that the WHS index recovers the handicap. For handicaps from 0 to 30, the 20-round index lands within ±0.3 of the preset's handicap (h 10 → 9.74, h 20 → 19.79, h 30 → 30.26; SIMULATED, 50 histories × 20 rounds per level, seed 1). The same script shows the handicap presets spreading out from one start, 150 yards in the fairway: 3.19 strokes for a scratch preset, 3.65 for a 10, 4.11 for a 20 and 4.40 for a 30 (SIMULATED, 2,000 balls each, seeds 500–503), against Broadie's tour value of 2.94.

⚠️ Common Pitfall: treating calibration as validation The amateur presets were tuned to hit Broadie's 2008 long-game shares and the WHS index. So "the simulator agrees with Broadie 2008" is partly true by construction: the simulator gives a long-game share of the amateur gap of about 59–61% at every level, against Broadie's 55%, 60% and 56% for his three amateur groups (Broadie 2008, Table 4, HIGH; SIMULATED comparison, 400 rounds, seed 3). A test the model was fitted to pass is a consistency check, not independent evidence. When a later chapter reports a SIMULATED finding, it tells you whether the finding was an input to the calibration or an output of it.

Known limits (stated once here, and again where they matter)

  • The simulator's amateurs putt and chip like Broadie's 2005–07 Golfmetrics golfers: compared with Shot Scope's users, they hit more greens, take more putts and get up and down less often.
  • The tour preset reproduces the 2003–10 baseline, which makes about 0.9 fewer one-putts per round than the 2026 PGA TOUR.
  • The geometry is flat and windless, and balls fly over trees. The fringe counts as fairway, and "recovery" means a tree zone, not Broadie's rule-based definition.
  • The ARG/APP boundary is golfkit's choice (next box).
  • Twenty rounds is a small sample: strokes-gained category estimates from 20 rounds have standard errors of about 0.3–0.7 strokes per round.

Definition: Around-the-Green (this book's version) golfkit defines an Around-the-Green (ARG) shot as a non-putt shot, other than a tee shot on a par 4 or 5, that starts within 30 yards of the edge of the green. The PGA TOUR's exact boundary is not verified in our references, so this is this book's (golfkit's) definition. A shot from farther out is Approach, and so are par-3 tee shots. The simulator records each shot's distance to the green's edge (start_edge_dist) so the rule can be applied exactly. For data without it, golfkit falls back to 40 yards from the hole, assuming 🧪 the pin sits about 10 yards onto the green.

The cast: six simulated golfers

The book's recurring characters are fictional, and their golf is simulated: yardbook.cast turns each into a Golfer with a documented quirk (the "truth" that later chapters try to discover from the data), and cast_rounds(name) plays 20 rounds on the member course with a fixed default seed.

# code/08_cast_and_schema.py (excerpt): the cast's simulated rounds
from yardbook import cast, rounds
for nm in cast.cast_names():
    shots = cast.cast_rounds(nm)                      # 20 SIMULATED rounds, default seed
    card = rounds.scorecard_from_shots(shots)         # this chapter's module (§2.10)
    print(nm, cast.CAST[nm]["seed"], card.groupby("round_id")["strokes"].sum().mean())
Cast member Index Default seed Shots Mean score (SD) Best–worst Putts GIR % Penalties/rd
Emma Sato +1.2 1210 1,441 72.35 (2.80) 66–78 31.65 71.1 0.30
Coach Tasha Nguyen 3.0 30031 1,541 77.85 (3.33) 72–83 32.10 54.7 0.80
Marcus Bell 7.8 78035 1,650 83.45 (4.63) 76–96 33.15 42.2 0.95
Dev Raman 12.0 120041 1,752 88.40 (4.50) 79–99 35.95 36.4 0.80
Rosa Delgado 15.4 154023 1,835 93.40 (5.81) 81–103 34.50 25.3 1.65
Walt Kowalczyk 18.9 189019 1,913 96.90 (4.67) 87–106 36.50 16.7 1.25

(All SIMULATED: golfkit.shotsim via yardbook.cast, member course, CR 70.8 / Slope 125 🧪.)

Each default seed gives a representative 20-round sample (see cast.py). It was chosen from 60 candidate seeds as the 20-round block whose strokes-gained profile is closest to that golfer's 600-round long-run profile, with the same biggest loss and biggest gain. That choice matters. With only 20 rounds a random seed can easily hide a golfer's true weakness, and the book wants Rosa's story (Anchor A: approach play, not putting, is her biggest leak) to be the one her long-run data tell. Chapters 14 and 28 show what other seeds look like. That sampling variation is a lesson of its own.

Figure 2.10 — The cast's simulated rounds

📊 Figure (described): A dot strip chart with one row per cast member, ordered by handicap index from Emma Sato (+1.2) at the bottom to Walt Kowalczyk (18.9) at the top. Each row shows 20 blue dots for 20 simulated gross scores on the par-72 member course, with an orange bar at the mean. The means are labelled 72.3, 77.8, 83.5, 88.4, 93.4 and 96.9. The spread widens with handicap: Emma's scores span 66–78, and Rosa's span 81–103. Marcus has one far-right outlier at 96.

Notice the spreads. Rosa's 20 rounds run from 81 to 103 and Marcus's from 76 to 96. If either golfer judged a swing change on two or three rounds, the noise would swamp the signal. That is theme 5, variance is the enemy of understanding, and it applies on tour too: a PGA TOUR player's rounds scatter around his own level with an SD of 2.756 strokes (computed from the real ESPN rounds; Chapter 14 builds on it), and the amateur SDs here are larger.

⚠️ Common Pitfall: attributing a simulated number to a real player The labelling rule is absolute. A number from golfkit.shotsim describes a simulated golfer and carries the SIMULATED label and its seed, in the text and on the figure (style.save(fig, path, note="SIMULATED — golfkit.shotsim, seed N")). A sentence like "Scheffler gains 1.3 strokes on approach (simulated)" is not allowed, because no simulation of Scheffler exists. Real players get real numbers (scores, field-adjusted strokes gained, finishes) or no number at all.

🔄 Check Your Understanding 1. The simulated tour golfer matches Broadie's baseline to within 0.05 strokes per cell over the main ranges. Name one thing that agreement does not prove. 2. Why are the cast's default seeds chosen rather than random? 3. A shot starts 35 yards from the edge of the green. Under this book's definition, is it ARG or APP?

Answers

  1. Any of these: that it matches today's tour; that the amateur presets match real amateurs; that the simulator's shot-pattern details (dispersion shape, mishit rates) are right. Agreement on average strokes doesn't validate every mechanism that produces them.
  2. A random 20-round block can easily hide a golfer's true biggest weakness. The chosen seeds are the representative blocks, so each cast story matches its long-run truth. Other seeds are shown deliberately in Chapters 14 and 28.
  3. APP. It starts more than 30 yards from the green's edge.

2.9 One Simulated Hole, Shot by Shot

Time to look inside. Marcus Bell is a 7.8-handicap aggressive pin-hunter. His simulated truth is a 1.5° right bias with 75% of his big misses going right, and he aims at every flag. Here he is on the demo hole water_right_approach_par4: 410 yards on the scorecard, water to the right of the green, the pin in its default position 7 yards right of centre (code/06_one_simulated_hole.py; SIMULATED, seed 7).

# code/06_one_simulated_hole.py (excerpt): play once, then price every shot
import numpy as np
from golfkit import baselines, holes, sg, shotsim
from yardbook import cast
marcus = cast.get_cast_member("Marcus")                    # SIMULATED golfer profile
hole = holes.demo_hole("water_right_approach_par4")        # 410 yd, water right of the green
shots = shotsim.play_hole(marcus, hole, rng=np.random.default_rng(7))   # one play, seed 7
priced = sg.strokes_gained(shots, baselines.Baseline.pga())             # vs PGA TOUR (Broadie)
print(priced[["shot_no", "club", "start_lie", "start_dist", "end_lie", "end_dist",
              "penalty", "e_start", "e_end", "sg", "category"]])
 shot_no club start_lie  start_dist start_unit end_lie  end_dist end_unit  penalty  holed  start_edge_dist
       1    D       tee       412.1      yards fairway     152.3    yards        0  False            395.0
       2   8i   fairway       152.3      yards   water      19.9    yards        1  False            135.8
       3   LW     rough        66.0      yards   green      21.4     feet        0  False             51.2
       4    P     green        21.4       feet   green       1.7     feet        0  False              0.0
       5    P     green         1.7       feet   holed       0.0     feet        0   True              0.0
Score on the hole: 5 swings + 1 penalty = 6 (par 4)

Read it row by row, the way you would read a ShotLink record.

  1. Driver from the tee, 412.1 yards from the hole (the pin sits a little behind the scorecard yardage), to the fairway with 152.3 to go. A good drive.
  2. 8-iron from 152 yards, at the flag, as always. It finishes in the water about 20 yards from the hole: penalty, one stroke.
  3. The drop is in the rough 66 yards from the hole. Note start_edge_dist = 51.2: the ball is more than 30 yards from the green's edge, so under this book's definition this lob wedge is an Approach shot, not Around-the-Green. It finishes 21.4 feet away.
  4. and 5. Two putts. Double bogey.

Now price each shot. Strokes gained for one shot is

$$ SG = E(\text{start}) - E(\text{end}) - 1 - \text{penalty strokes}, $$

where $E$ is the expected number of strokes to hole out from a position, here from Broadie's PGA TOUR baseline. In plain English: a shot gains strokes if it improves your position by more than the one stroke it costs. For the 8-iron: $E(\text{fairway}, 152.3) = 2.951$; the next shot is played from the drop, $E(\text{rough}, 66.0) = 2.922$; so $SG = 2.951 - 2.922 - 1 - 1 = -1.971$. The water cost him almost exactly two strokes against a tour player's expectation.

 shot_no club start_lie  start_dist end_lie  end_dist  penalty  e_start  e_end     sg category
       1    D       tee     412.059 fairway   152.290        0    4.007  2.951  0.056      OTT
       2   8i   fairway     152.290   water    19.906        1    2.951  2.922 -1.971      APP
       3   LW     rough      65.996   green    21.409        0    2.922  1.889  0.033      APP
       4    P     green      21.409   green     1.726        0    1.889  1.008 -0.119     PUTT
       5    P     green       1.726   holed     0.000        0    1.008  0.000  0.008     PUTT
Sum of shot SG = -1.993; check E(tee) − score = -1.993

The shot values add up to the hole's total, which equals $E(\text{tee}) - \text{score} = 4.007 - 6 = -1.993$. They always do. That identity is why strokes gained works as an accounting system (Chapter 10 develops it, and Chapter 11 splits it into categories).

Figure 2.11 — Marcus plays a 410-yard par 4 (one simulated play)

📊 Figure (described): An overhead map of the hole with the tee at the bottom and the green at the top, about 410 yards up. The fairway is a light-green strip, with rough on both sides and trees beyond. A blue water rectangle sits to the right of the green, and two sand bunkers sit to the left of it. Blue arrows trace the shots: the drive straight up the fairway to about 260 yards; the 8-iron angling right into the water; the lob wedge from the drop point in the right rough onto the green; and the two putts, labelled "2 putts → holed".

Figure 2.12 — The same hole, priced shot by shot

📊 Figure (described): Five bars of strokes gained per shot against the PGA TOUR baseline. The drive is +0.06 (blue), the 8-iron −1.97 (a tall orange bar), the lob wedge +0.03, the first putt −0.12 and the tap-in +0.01. The title gives the total of −1.99. One shot accounts for essentially the entire loss.

How typical was that?

One play of one hole is a single draw from a distribution. The script replays the hole 5,000 times with the same golfer and the same pin (SIMULATED, seed 2026):

Replay, 5,000 plays (seed 2026): mean 5.486, SD 1.97; P(water at least once) 0.357
Score distribution: {3: 0.023, 4: 0.271, 5: 0.311, 6: 0.218, 7: 0.085, 8: 0.041, 9: 0.021, 10: 0.013, ...}
P(score >= 6) = 0.395; median 5; P(score >= 10) = 0.030; max 78

With his pin-hunting policy and this pin, Marcus finds the water in 35.7% of plays and averages 5.49 on a par 4. The double bogey he made on seed 7 was not bad luck. Scores of 6 or worse happen 39.5% of the time. That is the setup for Anchor B (Chapters 18–21): the same golfer, aiming somewhere other than the flag, loses far fewer strokes on holes like this.

⚠️ Common Pitfall: the simulator's own quirk, 78 on a par 4 Look at the maximum: 78. In one of the 5,000 plays the simulated Marcus took 40 swings and 38 penalty drops. His drop point sat in the trees right of the water, and from there his lob wedge, played at the pin with recovery dispersion, kept finding the water. The simulator's drop rule always takes the "last dry point on the line back", and a real golfer would use another relief option (or simply aim away from the water). This is a simplification in the model, not golf. It is rare: 3.0% of plays reach 10 or more strokes, and capping every play at 15 strokes moves the mean only from 5.486 to 5.468. But it is a perfect reminder that simulators have quirks too, and you find them by looking at the tails. Report the median (5) alongside the mean when a tail like this exists.

🧩 Productive Struggle Before Chapter 19 shows you how: using only the replay output above, how would you estimate how many strokes per play Marcus would save if he never hit the water? (Hint: compare the mean score of plays with and without a water ball, and think about why that comparison overstates the saving.)


2.10 The yardbook Data Model: Recording Your Own Golf

The cast's rounds and your rounds should look the same to the code. This chapter's project module, yardbook/rounds.py, defines two tables and the checks that keep them honest.

One row per swing. These are the same columns golfkit.shotsim produces, so every tool in this book works on your data unchanged:

Column Meaning Example
round_id your round number or date code 1
hole, par hole number and par 1, 4
shot_no 1, 2, 3, … within the hole 2
club D 3W 5W 7W HY 2i … 9i PW GW SW LW P 8i
start_lie tee, fairway, rough, sand, recovery, green fairway
start_dist, start_unit distance to the hole: yards off the green, feet on it 148, yards
end_lie as above, plus water, ob, holed green
end_dist, end_unit where it finished, to the hole 22, feet
penalty penalty strokes added by this shot 0
holed True only on the last shot of the hole False
(optional) start_x, start_y, end_x, end_y hole coordinates in yards, + y = right
(optional) aim_x, aim_y where you aimed, same coordinates (Chapter 19's dispersion fits and Chapter 40's dashboard aim advice need them)

Two rules matter more than the rest. First, distances are to the hole, not distances hit: a 148-yard approach that finishes 22 feet away is recorded as start 148 yards, end 22 feet. Strokes gained needs positions, not club distances. Second, the units switch at the green: yards off it, feet on it, the same convention Broadie's baseline uses.

Table 2: the scorecard table

One row per hole, which is what you can copy from a paper scorecard in five minutes:

round_id, date, course, tees, course_rating, slope, hole, par, yards, strokes, putts, fairway, gir, penalties

The fairway column takes hit / left / right / short / long / miss (side unknown), or blank on par 3s. The gir column follows the book's definition: on the green in par − 2 strokes or fewer, penalty strokes included. You don't need shot data to keep a scorecard table. If you do have shots, scorecard_from_shots builds the scorecard for you, and on all six cast members it reproduces golfkit's own round totals, GIR counts and fairway counts exactly.

rounds.write_templates(folder) writes both as CSV files with example rows (code/templates/):

round_id,hole,par,shot_no,club,start_lie,start_dist,start_unit,end_lie,end_dist,end_unit,penalty,holed
1,1,4,1,D,tee,385,yards,fairway,148,yards,0,False
1,1,4,2,8i,fairway,148,yards,green,22,feet,0,False
1,1,4,3,P,green,22,feet,green,2,feet,0,False
1,1,4,4,P,green,2,feet,holed,0,feet,0,True

The template's numbers are a made-up example hole, there only to show the format. Delete them before you enter your own.

Validation: catching mistakes before they become insights

Hand-entered data is full of small errors, and strokes gained is merciless with them. A forgotten tap-in makes a 5 look like a 4. A putt logged in yards turns an 8-foot putt into a 24-foot one. validate_shots runs a set of checks and returns a report, not an exception, so you can see everything at once. To test it, code/08_cast_and_schema.py takes Rosa's clean 20 rounds and breaks a copy in five realistic ways: it removes the holed flag on one hole, deletes a shot, logs a putt in yards, forgets a water penalty and mistypes a distance by 40 yards.

# code/08_cast_and_schema.py (excerpt): validate the clean data, then the broken copy
rep = rounds.validate_shots(rosa)          # clean SIMULATED rounds
print(rep.summary())                       # "1,835 rows checked — 0 errors, 1 warnings"
rep = rounds.validate_shots(bad)           # the copy with five planted mistakes
print(rep.summary())
print(rep.issues.query("severity == 'error'")[["check", "round_id", "hole", "shot_no", "message"]])
shots: 1,834 rows checked — 7 errors, 1 warnings
  error   bad_unit                     1
  error   chain_break                  3
  error   not_holed_out                1
  error   penalty_missing              1
  error   shot_numbering               1
  warning distance_increase            1
       bad_unit         1     3      4.0      putt distance must be in feet
penalty_missing         2     1      1.0      water finish without a penalty stroke
  not_holed_out         1     1      NaN      no holed shot on this hole
 shot_numbering         1     2      NaN      shot_no [1, 3, 4, 5, 6]
    chain_break         1     2      3.0      shot 1 ends fairway 298.4 yards; shot 3 starts fairway 111.0 yards
    chain_break         1     3      4.0      shot 3 ends green 10.5 feet; shot 4 starts green 10.5 yards
    chain_break         2     4      2.0      shot 1 ends rough 128.1 yards; shot 2 starts rough 168.1 yards

All five planted mistakes are caught, and several are caught twice from different angles. The most powerful check is the chain check: each shot must start where the previous one finished (same lie, same unit, same distance within a yard), except after a water or OB finish, when the next shot starts from a drop or replay spot. It catches deleted shots, unit slips and typos together, because all three break the chain. The one warning (distance_increase) is a genuine simulated shot that finished farther from the hole than it started. That is legal but unusual, so it's worth a glance.

The same discipline applies to real data. validate_scorecard run over every 2026 Masters scorecard in the ESPN snapshot finds 5,220 hole rows, 0 errors, 0 warnings. Before the label fix the 2023 Open would not have passed so cleanly, and Case Study 1 shows why.

🔍 Why Does This Work? Why is the chain check so effective? Because a round of golf is a sequence of positions, and each shot is the move from one position to the next. Any single error in a hand-entered sequence (a missing row, a wrong unit, a typo) creates a jump between consecutive positions that no real shot made. Checking that consecutive rows connect turns many different mistakes into one detectable symptom. ShotLink's own data have the same structure, which is why each shot's end can be checked against the next shot's start.

📋 Play the Shot: one bad hole in the export Rosa's app died on the 12th hole of her seventh round, and she typed the hole in from memory: a drive to 157.6 yards, a 7-iron into the rough 36.3 yards out, a lob wedge to 21.3 feet and two putts. In her entry she remembered the 7-iron's start as 10 yards longer, logged the first putt in yards, and forgot the tap-in. Case Study 2 runs the loader: it reports 4 errors on that one hole (a chain break at shot 2, a unit error and a second chain break at shot 4, and "not holed out"). Left unfixed, the round would count as 95 instead of the true 96, and every downstream number (her strokes gained, her handicap differential, her practice plan) would inherit the error. The decision: fix the hole from what you remember for sure, and if you can't, drop the hole from shot-level analysis but keep the score on the scorecard.

⛳ On-Course Action For your next three rounds, keep a scorecard table: strokes, putts, fairway (hit / left / right) and penalties for every hole. It takes about five minutes per round with code/templates/scorecard_template.csv. If you're ready for more, track one nine in the shot table: write down the lie and the distance to the hole before each shot (a rangefinder number off the green, paced or estimated feet on it). Then run rounds.load_shots_csv on it and fix whatever the validator finds. You'll learn more about your recording habits from that one report than from a season of guessing.

🔄 Check Your Understanding 1. A 160-yard approach finishes 30 feet from the hole. What goes in start_dist, start_unit, end_dist and end_unit? 2. Shot 3 ends in the fairway 98 yards out, and shot 4 starts in the rough 98 yards out. Which check fires, and what is the likely mistake? 3. Why does the chain check skip the shot after a water ball?

Answers

  1. 160, yards, 30, feet.
  2. chain_break, because the lie changed between the end of one shot and the start of the next. Either the end lie or the start lie was recorded wrong (perhaps the ball was on the edge of the fairway and the two entries were made at different times).
  3. After a penalty the next shot is played from a drop or a replay spot, not from where the ball finished (it finished in the water). So the positions don't have to connect.

Project Checkpoint: rounds.py

This chapter adds the module every later yardbook chapter reads from: project/yardbook/rounds.py. It defines the data model for your golf and the checks that keep it honest. Its public interface:

Name What it does
SHOT_COLUMNS, SCORECARD_COLUMNS, LIES, END_LIES, CLUBS The schema, as constants
Shot(...) A validating dataclass for one swing (units default from the lie)
Round(...), Round.from_frame(card) A validating scorecard for one round; .score, .to_par, .to_frame()
validate_shots(shots) / validate_scorecard(card) Return a ValidationReport (.ok, .issues, .summary(), .raise_if_errors())
load_shots_csv(path) / load_rounds_csv(path) Read your CSVs, normalise column names, lies and units, and attach the validation report
scorecard_from_shots(shots, course=None) Shot table → scorecard table (strokes, putts, GIR, fairway, penalties)
wide_scorecard(card) One row per round with holes, out, in and total; also works on ESPN hole scores
write_templates(folder) CSV templates for manual entry

The checkpoint script (code/project_checkpoint.py) does what you'll do with your own export. It saves Dev Raman's 20 simulated rounds to a CSV with app-style column names (Round, Shot, Lie, Distance), loads them back, and builds the scorecards:

# code/project_checkpoint.py (excerpt)
shots = rounds.load_shots_csv(csv)                 # names normalised, report attached
print(shots.attrs["validation"].summary())
card = rounds.scorecard_from_shots(shots, member)  # one row per hole
wide = rounds.wide_scorecard(card)                 # one row per round
r1 = rounds.Round.from_frame(card[card["round_id"] == 1])
shots: 1,752 rows checked — 0 errors, 1 warnings
Rounds 1–3 as scorecards:
          1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  out  in  total
1         4  7  2  5  4  4  5  4  5   4   4   6   3   5   5   5   3   4   40  39     79
2         5  6  4  7  5  5  5  4  4   5   5   5   3   5   7   5   4   5   45  44     89
3         5  4  3  5  4  6  5  6  4   4   6   5   5   4   5   6   3   4   42  42     84
Round 1: 79 (+7) on Demo Member (6,400 yd), CR 70.8 / Slope 125
Course Handicap 12 | first five rounds: gross [79, 89, 84, 89, 84] AGS [79, 88, 83, 88, 84] differential [7.4, 15.5, 11.0, 15.5, 11.9]

(SIMULATED: Dev Raman, seed 120041; the member course rating is assumed 🧪.) Check one differential by hand. Round 1: $(113/125) \times (79 - 70.8) = 0.904 \times 8.2 = 7.41$, which rounds to 7.4. Then it runs the same tools on real data. McIlroy's 2026 Masters scorecard comes out of wide_scorecard unchanged from §2.6, and every one of the 5,220 hole rows of that Masters passes validate_scorecard.

How it plugs in later. Chapters 10 and 11 feed load_shots_csv output to golfkit.sg.strokes_gained. Chapter 19 fits dispersion ellipses from the shot table's coordinates. Chapters 28 and 29 track scorecards and handicaps from the scorecard table. Chapter 40's dashboard (python -m yardbook report --shots my_shots.csv) starts with these two loaders, and if the validation report has errors, the dashboard tells you before it tells you anything else.


Chapter Summary

The three sources. Real ESPN scores (1,061 events, 2004-01-11 to 2026-11-23; 1,031 usable; 7,535,490 hole scores; 4,221 players), SIMULATED shots from golfkit.shotsim with fixed seeds, and cited reference tables with confidence tags. Nothing else.

The pipeline.

Step Script Key idea
Download scripts/fetch_espn.py four phases; resumable to-do lists; write-then-rename; backoff 1→16 s; default User-Agent (custom strings got 403)
Flatten scripts/build_espn.py events → competitions → competitors → rounds → holes; par = strokes − relative; resolve unusable tags ("OTHER", impossible pars) from other scorecards; consensus par; par signatures
Stats scripts/build_player_stats.py per-player tournament stats 2015+; 0 means missing
Load golfkit.data derived flags; corrected outcome columns; course-round grouping

The quirks, with counts.

Quirk Count Handling
Build WD/DQ labels → genuine 4,741 → 3,542 (1,199 relabelled) status_fixed
Wrong winner in the build 4 events in the first pass; 0 now won_fixed
Unusable to-par tags ("OTHER" quad bogey+, impossible pars) 12,946 pars resolved, 134 not; complete rounds 416,529 → 417,380 in the second pass resolved in the build
ESPN season ≠ calendar year 93 events use year
Multi-course events 107 course-round grouping
Staggered-start TOUR Championships 6 (2019–2024) ESPN order for finishes
Non-stroke / team / exhibition / Q-School 17 / 8 / 8 / 9 excluded
Wrong ESPN pars 4 events par_ok False: kept for SG, excluded from to-par and hole stats
Minority pars out of line with the hole's consensus (e.g. a derived par 6) 443 corrected (1,282 par-6 rows before the fix; 0 now) consensus par; check pars against the course
Quality-screen failures 3 events kept for SG, not for outcomes
Player stats with driving distance 0 or missing 6,825 of 67,509 rows treat as missing

The formulas.

Formula Reading
$\text{par} = \text{strokes} - \text{relative to par}$ how every hole's par is derived from ESPN
$SG = E(\text{start}) - E(\text{end}) - 1 - \text{penalty}$ value of one shot vs a named baseline
$\sum SG_{\text{hole}} = E(\text{tee}) - \text{score}$ shot values add up to the hole
Differential $= (113/\text{Slope})(\text{AGS} - \text{CR} - \text{PCC})$ WHS, no 0.96 multiplier

Decision checklist before you trust any golf number: 1. Where does it come from: real, simulated (which seed?), or cited (which source, what confidence)? 2. Are the outcome columns the corrected ones? 3. Is the year a calendar year? 4. Were players compared only with others on the same course in the same round? 5. Did the joins check their shape (validate=), and do the totals agree across sources? 6. For shot data: does every shot start where the last one ended? 7. Have you looked at the tails, not just the mean?


What's Next

With the data in hand, we go back to the ball. Chapter 3 follows the half-millisecond of impact that turns a club delivery into the launch conditions Chapter 1 flew: smash factor, spin loft and the D-plane. When the book reaches strokes gained in Chapter 10, every number will come through the pipes you've just inspected.