Skip to main content

py-Goldsberry

A Python Package for easily acquiring NBA Data for analysis

What is py-Goldsberry?

py-Goldsberry is designed to give the user easy access to data available from stats.nba.com in a form that facilitates innovative analysis. With a few simple commands, you can have access to virtually any data available on the site in an easy to analyze format. In fact, some of the data is in a less summarize form giving you the opportunity to work with the most raw data possible when you are attempting to answer questions that interest you.

Why was it built?

I attended the 2015 Sloan Sports Analytics conference and had the fortunate opportunity to listen to Kirk Goldsberry address the crowd regarding the state of analytics in sports (You can watch the talk here). One of the questions he addressed at the end was related to the availability of data (or lack thereof in some instances). Basically, he concluded that the lack of availability of some of the newest data is actually hindering the progression of analytics in sports. Innovation is now restricted to those with access to data instead of to the entire community of interested parties. I wrote (am writing) this package in an attempt to help address this issue in whatever small way I can.

This package is a work in progress. As the NBA continues to make more data available, I will do my best to update py-Goldsberry to reflect these additions. Currently, there is almost a cumbersome amount of data available from the NBA so dealing with what is there is a bit of a challenge.

UPDATE: The NBA has apparently masked some of the tables that were previously available. The log level data is no longer available. This is disappointing as there was a multitude of research opportunities availble with the use of the data. Hopefully, the NBA will make this data available again in the near future.

Getting started

To get started with py-Goldsberry, you need to install and load the package. From your terminal, run the following command:

pip install py-goldsberry

Once you have the package installed, you can load it into a Python session with the following command:

import goldsberry
import pandas as pd

The package is designed to work with pandas in that the output of each API call to the NBA website it returned in a format that is easily converted into a pandas dataframe.

Getting a List of Players

One of the key variables necessary to fully utilize py-Goldsberry is playerid. This is the unique id number assigned to each player by the NBA. py-Goldsberry has a top-level class PlayerList() built-in to give you quick access to a list of players and numbers.

players2010 = goldsberry.PlayerList(Season='2010-11')
players2010 = pd.DataFrame(players2010.players())
players2010.head()

If you want a list of every game during the current season use the GameIDs() class:

games = goldsberry.GameIDs()
games = pd.DataFrame(games.game_list())
games.head()

As you get started with py-goldsberry, TAB completion in either Jupyter or IPython is going to be your best friend. I’m working on documetation, but there is a great deal of it to do and I don’t have that much time.

Metadata

Release files for py-goldsberry 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-goldsberry 1.1
File Size Uploaded
py-goldsberry-1.1.tar.gz 26.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-goldsberry 1.1
File Interpreter ABI Platform
py_goldsberry-1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 63.8 kB

Release files / py-goldsberry-1.1.tar.gz

Download URL py-goldsberry-1.1.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
393a77aaddf7d738c4d2f5a52c82aa3ba3cec624b9abb8cd36502b8b70cd95ef
BLAKE2b-256 checksum
How to use checksums
08a5d809148461f4b4b564706d3a156314c6e7f323f638923605f2487acedea0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1

Release files / py_goldsberry-1.1-py2.py3-none-any.whl

Download URL py_goldsberry-1.1-py2.py3-none-any.whl
Size 37.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b96dc88db2f0ac12d14a3c52868c1945ca1013d9000786a5f0bf3180d855c0cc
BLAKE2b-256 checksum
How to use checksums
169f810482396dd38dc7fc99ff41349988fc5a5aba2882bd47feba37a8aa1362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

1.0.1

2 release files

0.8.0

1 release file

0.7.1

1 release file

0.7

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page