Learn to Code with Fantasy Football

Learn to Code with Fantasy Football (LTCWFF) — available at fantasycoding.com — is a book I wrote mostly over the Summer of 2019.

It covers Python, Pandas (Python's main data analysis library), SQL, web scraping, public APIs, data visualization, summary stats and modeling, all applied to fantasy football.


The main target for the book are people who are:

  • into fantasy football
  • have done a bit of their own analysis in something like Excel
  • don't necessarily have much background in coding
  • are interested in learning more
  • unsure where to start

Which was basically me about 10 years ago.

The book has worked better for people who want to get into coding in an easy, digestible way as opposed to people who just want to win their leagues and are more indifferent to coding.

In other words, if your main objective is state of the art "who do I start" advice, it's much easier and more efficient to just buy a subscription to Fantasy Math (or 4 for 4 or whatever), then put in all the time and energy going through this book.

I think most people get that, and most of my readers have been people who are excited learning to code for themselves.

Market Research

I got the initial seed of an idea from a reddit post, which was about R and didn't end up going anywhere (though author did reach out to me after my book came out and was really nice about it).

I did one of my own posts on reddit to gauge interest (which there was a lot of) and start collecting emails.

Writing Process and Experience

Writing the book wasn't that difficult. I think that's more of a function of the topic — I've spent a lot of time thinking about fantasy football and a lot of time doing data science type tasks at my day job — than any natural skill as an author. I would guess future books on other topics might be tougher.

I also enjoy teaching and believe I'm pretty good at:

  • synthesizing/summarizing and finding themes/commonalities among large amounts of information
  • picking out a path to knowledge and introducing things at the right time
  • getting in the mind of the reader and finding and avoiding potentially confusing spots they might trip up on

At first I tried to write in prose form, but found that was way too slow, mostly because it was too hard to keep from trying to edit/rewrite/make perfect sentences as I went.

It was much easier for me to write out bullet points of the concepts I wanted to get across, even down to the sentence level (I do these writeups on my site the same way).

So I bulleted out the whole book, then rewrote it as prose.

Ray Dalio and Navigating Levels

I really like Ray Dalio's book Principles, and I often thought about the part in his book on navigating levels while writing and bullet pointing everything out.

Reality exists at different levels and each of them gives you different but valuable perspectives. ... We are constantly seeing things at different levels and navigating between them, whether we know it or not, whether we do it well or not... For example, you can navigate levels to move from your values to what you do to realize them on a day-to-day basis.

> I want meaningful work that's full of learning.
>> I want to be a doctor.
>>> I need to go to medical school.
>>>> I need to get good grades in the sciences.
>>>>> I need to stay home tonight and study.

According to Dalio, when a line of reason has gotten jumbled, it's often because the speaker is jumping around different levels without showing how they connect.

That's why, when conveying information, it's important to:

  • Be aware what level you're examining a given subject.
  • Consciously navigate levels rather than see subjects as undifferentiated piles of facts that can be browsed randomly.

Of course, I had always known that in theory, but explicitly keeping it in mind probably made the book better and has a lot to do with how the book has been received.

Format and Delivery

I released the book an en ebook (pdf, code, datasets, Anki cards) on Gumroad (update: I've moved to SendOwl), which I've generally been happy with.

It's really meant to be coded along with, and I think a pdf format is the best way to do that.

I've had a requests for hard copies, and in the future I may consider other options like Amazon publishing for those.


Reception has been very positive.

I offer a 30 day refund, and have had only a few people take me up on it.

As far as criticism (which I embrace — it's the most efficient way to make the book better by far), I've had a few people spot typos, which I expected given I never formally hired a copy editor. One benefit of the ebook format is I can fix them and rerelease it immediately, which I've done as they've come up.

Initially I didn't include any end of chapter exercises or problems, and I heard from a few people who wanted to be able to test themselves on the material. So recently I went back and added more than 100 problems with full solutions (most of them code).

Future Plans

I think there are people in other sports who would appreciate a similar book. I've released a baseball version and may do other sports depending on interest.

I also think the material may be good enough as a general purpose (non sports related) introduction to Python, Pandas and general data science practices. I've had a few readers who didn't know anything about football (much less fantasy football) read this book and get a lot out of it, which makes me think that may be a promising avenue. If I did that, I may explore working with a traditional publisher as well.