This project is a fast, condensed program to query NBA box score data, advanced box score data, and game reprots such as individual game summaries and officals' data. A single year takes roughly 6-8 hours to fully process.
For the year entered, three csv formmated files are filled:
- box_score_plus: Per game data on each player for every game in the season
- game_summaries: Game-by-game summary data on the teams that played, the broadcasting network, the game time, the game date, and the attendence
- total_officials: The names of the officials that refereed
box_score_plus is formatted as follows:
| Basic Info | Box Score | Adv. Box Score | Misc. Box Score | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
game_summaries and total_officials are formatted as follows:
| Officals | Game Summaries/th> | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Project is created with:
- Python 3.6, R
- py_ball: For NBA API Calls
- matplotlib: Dependency for the py_ball package
- pandas: For dataframe formatting
- requests_cache: For API calls, SQLite storing
- dyplr: For dataframe concatenation and processing
The following instructions are for Mac OS.
Follow the instructions and run the commands in Terminal:
Step 0: cd into a folder that you want to store the code/files generated
$ cd /Users/{Insert username}/Documents/{Whatever path you want to use}
Step 0: Clone the repository
$ git clone https://github.com/awx1/analysis_nba.git
Step 1: Install pip
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python get-pip.py
Step 0: Install virtualenv
$ python3 -m pip install --user virtualenv
$ pip3 install virtualenv
Step 3: Access virtual env
$ python3 -m venv nba
$ source env/bin/activate
Step 4: Install packages
$ pip3 install cairosvg==2.2.1
$ pip3 install matplotlib==3.2.1
$ pip3 install pkginfo==1.5.0.1
$ pip3 install requests==2.20.0
$ pip3 install py_ball
$ pip3 install matplotlib
$ pip3 install pandas
$ pip3 install requests_cache
Step 5: Install homebrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Step 6: Install cairo
$ brew install cairo
Step 7: Place this line of code at the bottom of final_copy.py (Specify the YEAR)
### Change the year here
get_year_boxscores({YEAR_HERE})
Step 9: Run the program using the command
python3 final_copy.py
Step 10: To concatenate the csv's using the R script, change the path to the correct path to run