Learn to Code with Baseball

Learn to Code with Baseball — available at codebaseball.com — is the baseball adaptation of Learn to Code With Fantasy Football.

I wrote it early in 2020, put it down for a while due to Covid, and picked it back up in the fall.

Like the football version, it covers Python, Pandas (Python's main data analysis library), SQL, web scraping, public APIs, data visualization, summary stats and modeling.

Writing Process

Because the original football version is much more focused on teaching programming and data science basics, which are similar across domains (including non sports domains!), porting the same concepts to baseball was fairly straightforward.

Baseball is much more stat heavy than football, which helped. I personally don't follow it as much as football, which didn't help. But I did some research, and I do like reading baseball books (Moneyball is an all time favorite, also really liked The Only Rule is It Has to Work).

One difference is that baseball is much more focused on good composite stats and measuring individual vs (fantasy) football, and the analysis portion of the book reflects that.