Git Product home page Git Product logo

py-goldsberry's Introduction

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.

py-goldsberry's People

Contributors

bradleyfay avatar danielmcintosh1 avatar git-bruton avatar omermazig avatar zsgilber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py-goldsberry's Issues

Daily scoreboard/Schedule unavailable

NBA endpoint changed:

goldsberry.league.daily_scoreboard(start_date)
""Please use the SET_parameters method to set the following paramters

Referral Denied

You don't have permission to access "http: """

I looked around for another endpoint instead of "scoreboardV2" but no luck.
My best idea would be to parse the "scores" page instead - http://stats.nba.com/scores/#!/02/24/2016

Any ideas/suggestions?

Python 3

Latest update of Goldsberry is not compatible with Python 3.

Testing

Need to develop and integrate testing framework for the package.

Typo in _apiFunc.py

line 28:
return '{0}-{1}'.format(y, str(int(y) % 100 + 1)[-2:].zfill(2))
should be:
return '{0}-{1}'.format(x, str(int(x) % 100 + 1)[-2:].zfill(2))

Thanks for all the hard work!

Python 2 compatibility

each data pull uses the zip functionality in Python 3. Need to figure out how to handle this in Python 2 and then how to make the script test which version of Python and move down that tree accordingly.

Any other nuances that need adjustments, document here

masterclass.py ObjectManager: get_table_from_data vs. _get_table_from_data

I installed the latest version of py-goldsberry in a Docker container running jupyter:minimal-notebook and ran into this problem with goldsberry.game.game_list(). It looks like all of the classes in goldsberry/game/_Game2.py use get_table_from_data instead of the function that appears in masterclass.py.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-23f0eefca570> in <module>
----> 1 games.game_list()

/opt/conda/lib/python3.7/site-packages/goldsberry/game/_Game2.py in game_list(self)
    139 
    140     def game_list(self):
--> 141         return self.object_manager.get_table_from_data(self.object_manager.data_tables, 0)
    142 
    143 

AttributeError: 'ObjectManager' object has no attribute 'get_table_from_data'

@staticmethod
def _get_table_from_data(nba_table, table_id):
try:
headers = nba_table['resultSets'][table_id]['headers']
values = nba_table['resultSets'][table_id]['rowSet']
except:
headers = nba_table['resultSet'][table_id]['headers']
values = nba_table['resultSet'][table_id]['rowSet']
return [dict(zip(headers, value)) for value in values]

getting a list of game id's

is there a function to call that returns a list of game IDs for a specified time period?

Thanks in advance!

Not pulling 2015 data?

It could very well be that I'm doing something wrong, but I can't seem to get any data from the current season. I'm able to infer that this data is indeed supplied by the API because I can get with nba_py, which is a much less convenient package.

Getting Usage Rate for NBA Player

hi

do you have a way to get this?

Usg% Usage Percentage =
100 * ((FGA + 0.44 * FTA + TOV) * (Tm MP / 5)) / (MP * (Tm FGA + 0.44 * Tm FTA + Tm TOV))

Update package on pypi

Hey @bradleyfay :-)

I've made contributions to this repo several years ago. My code is already on master, and I would love for the version on Pypi to be updated with it (This is the diff - v1.1...master). I'm importing this project in another project of mine, and it would simplify my dependency management (Eliminating the need to clone this repo manually).

I don't plan to add more to this project, but I am currently in the midst of job interviews, and would like to simplify my repo's dependencies to make it easier for recruiters to observe and use :-)

I understand if this project isn't actively maintained on your end, but I prefer the original package to be updated rather than uploading my own, as I want to ensure credit is attributed where it's due.

Thank you!

duplicate _PerMode() helper functions

There are duplicate functions in _apiFunc.py.

Need to name these differently and go through and identify which pulls require each function to work properly.

List of Game IDs

Need to build in a list of game ids so a user can have a list of valid ids.

API pull error

All API requests are producing no json detected errors. Issue appears to be occurring for many NBA API users but thought useful to post here.

Documentation

Building out documentation for the package to ease use

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.