Bonus Post: NBA_py Functions Workbook Now Available

Dan Watson
Hardwood Convergence
3 min readAug 1, 2019
Source: Wikimedia Commons

The Plan

This isn’t going to be a real post where we learn something new. I‘m started this post at 5am on Tuesday morning and I’m still not fully awake. Instead of starting something low quality, I made a notebook with all the nba_py functions as a usable reference guide for y’all. More importantly, we’re going to ramp up quickly later this week, so enjoy this quick bonus blog.

In the last post we learned how to pull nba game logs with nba_py. The post linked the documentation for nba_py, but I figured you may have skipped that. So here we’ll just quickly describe the modules available. More importantly, I put all the available functions a notebook so you can start playing with this data. This is probably a notebook you’re going to want to reference from time to time, so grab it from our github.

Scoreboard Module

Scoreboard lives by itself outside any of the modules in nba_py. I typically use Scoreboard as a way to pull every game_id from a particular date so I can pull stats. For this purpose, I’d usually use the .available() or game_header() methods, but Scoreboard also has standings over time, game lines, season series stats, and last meetings results.

Team Module

The team module is where we get some basic information like team ids, rosters, coaches, and history, along with game logs and team performance splits. All the functions other than the team list require a team id, so make sure to look those up first. I think there is a ton of great information available in the TeamLineups and TeamPassTracking functions!

Player Module

As you’ve guessed, this module revolves around the players. These functions require a player id, which is available through the rosters or you can use the player lookup function, but that function is a bit sensitive with it’s matching so it’s not ideal. Anyway, here you can get career stats, college stats, clutch shooting statistics, game logs, rebound information, etc. This is a module you’ll focus on when doing player v player comparisons, so check out the functions and start learning what’s here.

Game Module

This module revolves around specific games and will require you to reference a game id, thus why we started with the Scoreboard. This is a great place to get game logs that contain all the basic player data we need to start analyzing team and player performance. The PlayerTracking function has really cool functionality around player speed and distance traveled on the court that we may be able to leverage to get an idea of player loads, activity levels, and rest.

Wrapping Up

Super short post today. Really just wanted to give you some idea of the scope of this package and encourage you to get your hands dirty with it.

Next post we start pulling this data in larger quantities- stats for all players and games over multiple seasons. After that we’ll create our database and ramp up our analyses. Really looking forward to it!

As always, I really appreciate you all following along with me! Please leave any comments or suggestions below and hit that clap button so I know you’re here!

--

--

Dan Watson
Hardwood Convergence

Data nerd, basketball fanatic, and ice cream connoisseur. Health care analytics by day, basketball analytics by night. https://www.linkedin.com/in/danielkwatson