Free course · Beginner · 10 parts · ~63 min

Python Foundations for Sports Data

Zero to competent: install Python, learn pandas on real standings, and finish by building a league table from raw results.

This is the on-ramp. Ten tutorials that take you from a bare machine to comfortably loading, reshaping, joining and cleaning real sports data in pandas. Every later course on this site quietly assumes the skills in this one.

The running example is real: actual MLB standings, actual messy stat tables. By the last step you'll turn a raw list of game results into a sorted standings table — the hello-world of sports analytics, built entirely by you.

What you'll be able to do

  • Set up Python, pandas and matplotlib and know what each is for
  • Filter, sort, derive and aggregate columns without reaching for a spreadsheet
  • Join datasets, reshape them with pivots, and clean the mess real data arrives in
  • Build a standings table from raw results, end to end
Download the course bundle - every script + dataset, one ZIP

The bundle contains each part's finished script, the shared helpers, and the sample data they read, with a README listing the run order - the whole course works offline.

The syllabus

Pace: A part per sitting, two weeks at an easy pace. Parts 4-8 can be taken in any order; the rest are sequential.

  1. Setting Up Python for Sports Analytics: A Complete Beginner's WalkthroughBeginner · ~8 minEverything else assumes a working toolchain; do this once, properly.
  2. Pandas for Sports Data: The 12 Operations You'll Use ConstantlyBeginner · ~8 minThe twelve operations you'll use in every project that follows.
  3. Your First Sports Data Visualization with matplotlibBeginner · ~6 minNumbers persuade nobody until they're a picture; make your first one early.
  4. Filtering and Querying a DataFrameBeginner · ~5 minSubsetting is the real workhorse - most analysis is picking the right rows.
  5. Computing New Columns: Rate Stats and Feature EngineeringBeginner · ~5 minRaw columns are rarely the stat you want; rates and differentials come first.
  6. Apply and Map: Custom Column Logic in pandasBeginner · ~5 minFor transformations no built-in covers: your own logic, applied down a column.
  7. Merging and Joining Two Datasets with pandasBeginner · ~5 minReal questions usually need two tables; joins are how tables meet.
  8. Group, Pivot, and Reshape: Aggregating Sports Data Like a ProIntermediate · ~8 minAggregation turns game-level rows into team-level answers.
  9. Cleaning Messy Sports Data: Real-World Fixes for Real-World FilesIntermediate · ~8 minReal data arrives broken; this skill separates finishers from starters.
  10. Build a Standings Table from a Season of Game ResultsIntermediate · ~5 minThe finale: raw results in, sorted standings out - everything above, used at once.

Check yourself

Five questions, graded on the page, nothing recorded anywhere - pick an answer and the explanation appears.

1. You have a DataFrame of teams and want only the teams with more than 90 wins. Which operation is that?

2. df.groupby('team')['runs'].mean() returns…

3. Joining a standings table to a payroll table requires…

4. Which of these is a rate stat rather than a counting stat?

5. One team appears as 'NYY', 'N.Y. Yankees' and 'Yankees' in the same column. That's primarily a problem of…

Where next: Sports Data Visualization · Statistics for Sports Data.