Animating NBA Games with Matplotlib and Pandas

Ted Petrou
Dunder Data
13 min readNov 8, 2018

--

In this tutorial, game 7 of the 2016 NBA finals will be animated with Matplotlib one shot at a time within a Jupyter Notebook. This tutorial integrates many different topics including:

  • Using the developer tools of a browser to discover non-public APIs
  • Using the requests library to get data into a Pandas DataFrame
  • Creating a static visual representation of an NBA court with shots from a game using Matplotlib
  • Creating a Matplotlib animation showing the description, score, time remaining, and player image for each shot taken

Full Tutorial on Github

Only a portion of the code has been included in this post. Please visit the official Dunder Data Github organization’s Matplotlib Tutorials page to download the complete tutorial.

Become an Expert

If you want to be trusted to make decisions using pandas, you must become an expert. I have completely mastered pandas and have developed courses and exercises that will massively improve your knowledge and efficiency to do data analysis.

  • Master Data Analysis with Python — My comprehensive course with 800+ pages, 500+ exercises, video lessons, multiple projects, and detailed solutions that will help you…

--

--

Ted Petrou
Dunder Data

Author of Master Data Analysis with Python and Founder of Dunder Data