Overview
Defensive metrics datasets track individual player defense including opponent shooting when guarded by the player, rim protection, defensive field goal percentage (DFG%), and defensive impact statistics. This data enables analysis of defensive effectiveness and shot contestation.Data Files
Defense Master
Comprehensive defensive statistics
defense_master.csv(Regular Season)defense_master_ps.csv(Playoffs)
Opponent FG%
Overall opponent shooting statistics
dfg.csv/dfg_p.csv
Rim Defense
Rim protection metrics (< 6 feet)
rimdfg.csv/rimdfg_p.csv
Rim Accuracy
Opponent accuracy at rim when contested
rim_acc.csv/rim_acc_p.csvrimfreq.csv/rimfreq_p.csv
Schema: Defense Master
File:defense_master.csv / defense_master_ps.csvGenerated by:
defense.py + organize_defense.pyRecords: ~20,000+ player-season records
Source: Combined NBA.com and pbpstats.com data
Core Fields
- Identifiers
- Overall Defense
- Rim Protection
Sample Data
Schema: Opponent Field Goal %
File:dfg.csv / dfg_p.csvGenerated by:
defense.pySource: NBA.com leaguedashptdefend endpoint
NBA.com player ID
Player name
Team ID
Team abbreviation
Player position
Player age
Games played
Games started
Frequency of defensive matchups (0-100 scale)
Defensive field goals made (opponent)
Defensive field goal attempts (opponent)
Defensive field goal percentage (opponent FG% when guarded)
Expected opponent FG% (league average for those shot types)
Difference between DFG% and expected FG% (negative = good defense)
Season year
Schema: Rim Defense
File:rimdfg.csv / rimdfg_p.csvPurpose: Tracks opponent shooting at the rim (< 6 feet) when contested by player Fields identical to
dfg.csv but filtered for rim attempts only.
Schema: Rim Accuracy & Frequency
Files:rim_acc.csv/rim_acc_p.csv- Opponent accuracy at rimrimfreq.csv/rimfreq_p.csv- Frequency of rim attempts allowed
pbpstats.com Fields
pbpstats.com Fields
Understanding Defensive Metrics
Negative DIF% is Good Defense
DIFF% = -5.0means opponents shoot 5% worse than expectedDIFF% = +3.0means opponents shoot 3% better than expected (poor defense)
Key Concepts
Defensive Field Goal % (DFG%)
Defensive Field Goal % (DFG%)
The field goal percentage of shots taken when a specific player is the closest defender. This measures how well a player contests shots.Formula:
DFG% = DFGM / DFGA * 100Lower DFG% = Better defenseDifferential % (DIFF%)
Differential % (DIFF%)
Compares opponent’s actual shooting percentage to their expected FG% based on shot type and location.Formula:
Positive differential = Player allows better shooting than expected
DIFF% = DFG% - Expected_FG%Negative differential = Player forces worse shooting than expectedPositive differential = Player allows better shooting than expected
Rim Protection
Rim Protection
Defensive metrics specifically for shots taken within 6 feet of the basket. Elite rim protectors have:
- Low
rim_dfg%(< 50%) - High
rim_dfga(high volume of rim contests) - Negative
rim_dif%(force misses)
Usage Examples
Find Elite Rim Protectors
Overall Defensive Impact
Rim Protection vs Perimeter Defense
Track Individual Matchup Performance
On-Court Rim Defense (Team Context)
Defensive Position Analysis
Data Collection Scripts
defense.py
Collects DFG% data from NBA.com and pbpstats.com
organize_defense.py
Combines defensive datasets into defense_master.csv
Important Notes
- DIFF% is the key metric: Measures defensive impact relative to expected performance
- Volume matters: High DFGA indicates a player who defends frequently (usually starters)
- Context: Big men typically have lower DFG% due to rim protection, guards contest more perimeter shots