Have you ever wondered how NBA statisticians aggregate box scores from the play-by-plays after an NBA game? It’s easy enough summing up the values for each metric, but how does Plus Minus (+/-) get calculated?

Plus Minus (+/-) is a metric that defines a player’s impact on the game and it is calculated as the difference between their team’s total scoring versus their opponent’s when the player is on the court.

This article is a little technical as we’ll be using Python to aggregate NBA play-by-play data. Below we’ll demonstrate how to calculate Plus Minus (+/-) for your own Python practice. If you would like to see all the code, please check out my Github here.


First off we would like to extend our thanks BigDataBall for generously providing us with data for this article. If you did not know, NBA data is difficult to scrape in large volumes and expensive to purchase otherwise.


Import Data

PbP_df = pd.read_csv('../data/2017-18_pbp/{}'.format(hou_gsw))
PbP_df.head()

Image for post

#nba #data-wrangling #python

How to Calculate Plus Minus From NBA Play-By-Play Data Using Python
2.20 GEEK