Download and Analyze Yahoo Fantasy Football Data

Chris Altonji
6 min readSep 19, 2020

--

My Fantasy Football league just kicked off its 13th year, meaning I have now been pretending to be the manager of an NFL team for half my life. Every year, 9 friends and I get together in person to draft our teams and then for the following 4 months (and much of the 8 month “off-season” following), all we talk about is Football. Almost every year I lose, finishing dead last more than I’ve made the playoffs, but that’s not the point. The point is that our league is important to me and by extension, so is our league’s data.

I built a single click process for downloading Yahoo! Fantasy Football data. It can be run entirely in browser using Python code that is hosted in Google Colab. I’ve only scratched the surface here, but I’ll present the questions I’ve tried to answer about my own league using Yahoo data. Afterwards I’ll show you how to do the same process of downloading and analyzing this data for your leagues.

Who is the worst manager in our league?

Like I said, I’m not great at Fantasy Football, but the first question I wanted to ask was, am I the worst? We used to have a rotating crew of friends involved, but for the last 6 years we’ve had the exact same group in our fantasy football league. Here are our yearly ranks for those 6 years:

It’s clear here that Greg A and I (Chris A) are in the running for worst managers. But these ranks include the playoff crapshoot. So a better thing would be to look at overall records.

Unfortunately, with 32 wins and 46 losses, I have the worst record in our league. I mean there’s always next year though?

What would have happened last year if everyone played their optimal lineup every week?

It’s tough when you leave a high scoring player on your bench, it’s heart wrenching when that player puts up 50 points. These were the 10 best performances by benched players in our league in 2019:

Who could blame Joe for not starting Trubisky in week 14 (the first week of the playoffs)? We do a 2 QB league, and his other 2 QBs were Mahomes and Dalton. He barely lost in week 14 though, starting Trubisky would have gotten him the win and kept him in the playoffs.

Mistakes like that are part Fantasy Football. But it’s interesting to consider what would have happened without those mistakes. How would the league have turned out if every week, everyone played their highest scoring lineup? I checked what would have happened, these were the results:

Interestingly, the bottom four still would have been in the bottom 4 in what I’m calling the “optimal” scenario. Points_lost is the number of points that could have been gained by starting the highest scoring players. Matt M and Robert had the lowest points_lost and we also see that in the optimal scenario, they both would have fared a lot worse. This tells me that their success was the product of good lineup setting.

What was the worst trade last year?

Last year was a relatively trade heavy year for us with 7 trades. To assess these trades, I first simply looked at the total amount of points received by either manager from the trade. Here is each trade and the sum of points that traded players received after the trade:

Trades 2 and 5 were trades for picks so only one side received a player. Interestingly, last year, the initiator of the trade always received less points than the receiver of the trade.

With these point totals, it’s still hard to say what was the worst trade. Robert for example seems to have fared better than Matt with Trade 6, but Matt finished ahead of Robert in the regular season, and they both finished in the top 4, so did that trade even matter? The real question I want to know, is what would have happened if that trade hadn’t occurred. I reversed each trade, and then evaluated the “optimal” scenario where everyone plays their best lineup. This is compared to the optimal ranks calculated above. Here were the results:

So what was the worst trade? Surprisingly, it wasn’t Sam who gave up McCaffrey. That was bad, and in the optimal scenario, had Sam not traded McCaffrey, he would have made the playoffs (top 6).

The worst trade however was more likely Trade 6, Matt M gave away Derrick Henry, without that trade he could have been first overall going into the playoffs.

How to run this for your own league

I took care to make this as easy to follow as I could. I built a website to sign into Yahoo. I hosted my code in Google Colab. You don’t need to be able to code to run these Google Colab Notebooks, though you’ll need to look at a bit of code and update a few fields in the code.

Ref: “Who is the worst manager in our league?”

In the first section, titled “Who is the worst manager in our league?” I do cross year comparisons. To run that analysis, follow all the steps in this Notebook: RanksPerYear.ipynb. You can make edits directly in the Notebook, if you try to save your changes Google Drive will ask you to save your own copy.

Ref: “What would have happened last year if everyone played their optimal lineup every week?” and “What was the worst trade last year?”

These sections require player all player data for a year. Getting that data requires hundreds of API requests to Yahoo so I made one Notebook to download a bunch of CSVs containing league info and another Notebook to upload those CSVs to and run analysis.

Step 1: Download all league data for a year by running this Notebook step by step: DownloadYahooFFSingleLeagueData.ipynb.

2: Upload all downloaded files to this notebook, change the filenames if needed, and run this script: EvaluateSingleLeagueFFDataForBlogPostOctober2020.ipynb

When you scroll down to the results section you should see the generated tables, hidden among some code:

Next Steps

Yahoo Fantasy Football is a fun trove of information. If you have any other ideas for how to use this or you need help for running it in your own league, don’t hesitate to reach out: caltonji@gmail.com.

--

--

Responses (4)