Created
November 25, 2019 01:44
-
-
Save basketballrelativity/01742b124408475caf63e5ce1acfb335 to your computer and use it in GitHub Desktop.
Shooting statistics by defender distance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from py_ball import player, league | |
| HEADERS = {'Connection': 'close', | |
| 'Host': 'stats.nba.com', | |
| 'Origin': 'http://stats.nba.com', | |
| 'Upgrade-Insecure-Requests': '1', | |
| 'Referer': 'stats.nba.com', | |
| 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2)' + \ | |
| 'AppleWebKit/537.36 (KHTML, like Gecko) ' + \ | |
| 'Chrome/66.0.3359.117 Safari/537.36'} | |
| pd.options.mode.chained_assignment = None # Disabling pandas SetWithCopyWarnings | |
| league_id = '00' #NBA | |
| player_id = '202710' | |
| season = '2018-19' | |
| team_id = '0' | |
| game_id = '0' | |
| per_mode = 'Totals' | |
| players = player.Player(headers=HEADERS, | |
| endpoint='playerdashptshots', | |
| league_id=league_id, | |
| player_id=player_id, | |
| season=season, | |
| team_id=team_id, | |
| game_id=game_id, | |
| per_mode=per_mode) | |
| players.data.keys() | |
| defender_dist_df = pd.DataFrame(players.data['ClosestDefenderShooting']) | |
| defender_dist_df.T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment