Skip to content

Commit

Permalink
First working code
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieBallingall committed Sep 2, 2024
1 parent a978f29 commit bd0b175
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
"# nba_api"
# NBA API demo

A proof-of-concept / demo for the `nba_api`

# To create the environment from scratch
conda create -n nba python=3.12
conda activate nba
conda install pandas
pip install nba_api

Then run
```
python main.py
```

Expect to see a large printout of a dictionary object beginning:
```
PLAYER_ID SEASON_ID LEAGUE_ID TEAM_ID TEAM_ABBREVIATION PLAYER_AGE GP ... REB AST STL BLK TOV PF PTS
0 203999 2015-16 00 1610612743 DEN 21.0 80 ... 560 189 79 50 104 208 796
1 203999 2016-17 00 1610612743 DEN 22.0 73 ... 718 359 61 55 171 214 1221
2 203999 2017-18 00 1610612743 DEN 23.0 75 ... 803 458 90 61 210 212 1385
```

We are using the API library:
https://github.com/swar/nba_api

There may be additional data available at through other libraries. See:
https://medium.com/@cristianvaldez85/nba-data-using-python-82ebc0e19398
10 changes: 10 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from nba_api.stats.endpoints import playercareerstats

# Nikola Jokić
career = playercareerstats.PlayerCareerStats(player_id='203999')

# pandas data frames (optional: pip install pandas)
print(career.get_data_frames()[0])

# dictionary
# print(career.get_dict())

0 comments on commit bd0b175

Please sign in to comment.