Introduction to Pandas Using Play-By-Play

By popular demand, attached you will find basic course materials that I developed for a sports analytics course taught at UW-Madison. The goal is simple: introduce Pandas and show how column manipulations, groupings, and report building could be accomplished.

This was a working document at the time; and has not been updated since the course. That said, the document effectively breaks down play-by-play data to build a box score and look at 5-man lineups.

Enjoy!

Document: PythonPandasExample

By the way, this document is the precursor to developing 5-on-5 stats such as this Minnesota Timberwolves one from mid-season in the 2017-18 NBA season:

Screen Shot 2018-10-11 at 11.30.30 AM

5 thoughts on “Introduction to Pandas Using Play-By-Play

  1. I’m interested in doing something similar in terms of calculating net rating and statistics for five-man lineup combinations in the NCAA. Did you generate the CSV file(besides the tracking data)by reading the play-by-play data into python and running code to create the csv?

    Like

    • No, it’s a generated csv that is delivered to me as content. For NCAA content, you may be able to track down Will Schreefer on Twitter.

      I’d be very careful about NCAA data, however, line-ups are not done correctly and even Will can only clean up so much.

      Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.