Overview
Theplayer_shooting.py script collects shooting statistics categorized by closest defender distance. Data is collected in four defender distance buckets: Very Tight, Tight, Open, and Wide Open.
Data Sources
- NBA.com Stats API:
leaguedashplayerptshotendpoint - Defender Distance Classifications:
- Very Tight: 0-2 feet
- Tight: 2-4 feet
- Open: 4-6 feet
- Wide Open: 6+ feet
Core Function
get_playershots()
Collects shooting data for all defender distance categories.List of years to scrape (e.g.,
[2024, 2025])Playoffs mode - if True, fetches playoff data
master_shooting()
Combines individual year files into master dataset.If True, processes playoff data
pd.DataFrame with all years and shot types combined
Statistics Collected
NBA player ID
Player name
Team abbreviation
Player age
Games played
Games started
Frequency percentage - how often player takes shots in this defender distance range
Field goals made
Field goal attempts
Field goal percentage (0-100 scale)
Effective field goal percentage (accounts for 3-pointers)
Two-point shot frequency within this defender distance
Two-point field goals made
Two-point field goal attempts
Two-point field goal percentage
Three-point shot frequency within this defender distance
Three-pointers made
Three-point attempts
Three-point percentage
Output Files
Individual Year Files
Shots with defender 0-2 feet awayPath:
{year}/player_shooting/very_tight.csv or {year}/playoffs/player_shooting/very_tight.csvShots with defender 2-4 feet awayPath:
{year}/player_shooting/tight.csvShots with defender 4-6 feet awayPath:
{year}/player_shooting/open.csvShots with defender 6+ feet awayPath:
{year}/player_shooting/wide_open.csvMaster Files
All regular season data combined (2014-2025)Additional columns:
year, shot_typeAll playoff data combined (2014-2025)Additional columns:
year, shot_typeColumn Mapping
The script renames NBA.com columns to more readable names:Usage Example
Analysis Use Cases
- Shot quality analysis: Compare FG% across defender distances
- Player evaluation: Identify players who create their own shot (high very_tight volume)
- Catch-and-shoot specialists: High FG% on wide_open shots
- Contested shooting ability: Performance on very_tight and tight shots
- Shot selection: Frequency distribution across defender distances