data.nba.com Enhanced PBP

Ejection

class pbpstats.resources.enhanced_pbp.live.ejection.LiveEjection(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.ejection.Ejection, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for Ejection events

action_type = 'ejection'

End of Period

class pbpstats.resources.enhanced_pbp.live.end_of_period.LiveEndOfPeriod(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.end_of_period.EndOfPeriod, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for end of period events

action_type = 'period'
sub_type = 'end'

Enhanced PBP Factory

LiveEnhancedPbpFactory can be used to create enhanced pbp event objects from the pbpstats.resources.enhanced_pbp.live module based on the event type.

The following code will get the event class for a turnover event

from pbpstats.resources.enhanced_pbp.live.enhanced_pbp_factory import LiveEnhancedPbpFactory

factory = LiveEnhancedPbpFactory()
event_class = factory.get_event_class('turnover', 'out-of-bounds')
print(event_class)  # prints "<class 'pbpstats.resources.enhanced_pbp.live.turnover.LiveTurnover'>"
class pbpstats.resources.enhanced_pbp.live.enhanced_pbp_factory.LiveEnhancedPbpFactory[source]

Bases: object

Class for factory of event type classes. On initialization will load in all event classes in the pbpstats.resources.enhanced_pbp.live module

get_event_class(action_type, sub_type)[source]

Gets the class for the event based on the event_type

Parameters:action_type (str) – event action type for the event
Returns:class for event type

Enhanced PBP Item

LiveEnhancedPbpItem is the base class for all live data enhanced pbp event types

class pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem(item, game_id)[source]

Bases: pbpstats.resources.enhanced_pbp.enhanced_pbp_item.EnhancedPbpItem

Base class for enhanced pbp events from live data

Parameters:
  • item (dict) – dict with event data
  • period (int) – period in which event occurs
  • game_id (str) – NBA Stats Game Id
data

returns event as a dict

event_stats

returns list of dicts with all stats for event

get_offense_team_id()[source]

returns team id for team on offense for event

is_possession_ending_event

returns True if event ends a possession, False otherwise

seconds_remaining

returns seconds remaining in period as a float

stripped_descriptor
stripped_sub_type

Field Goal

class pbpstats.resources.enhanced_pbp.live.field_goal.LiveFieldGoal(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.field_goal.FieldGoal, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for field goal events

action_type = ['2pt', '3pt']
is_made

returns True if shot was made, False otherwise

shot_value

returns 3 if shot is a 3 point attempt, 2 otherwise

Foul

class pbpstats.resources.enhanced_pbp.live.foul.LiveFoul(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.foul.Foul, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for foul events

action_type = 'foul'
is_away_from_play_foul
is_charge
is_clear_path_foul
is_defensive_3_seconds
is_delay_of_game
is_double_foul
is_double_technical
is_flagrant1
is_flagrant2
is_inbound_foul
is_loose_ball_foul
is_offensive_foul
is_personal_block_foul
is_personal_foul
is_personal_take_foul
is_shooting_block_foul
is_shooting_foul
is_technical
is_transition_take_foul
number_of_fta_for_foul

returns the number of free throws resulting from the foul

Free Throw

class pbpstats.resources.enhanced_pbp.live.free_throw.LiveFreeThrow(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.free_throw.FreeThrow, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for free throw events

action_type = 'freethrow'
is_away_from_play_ft

returns True if free throw is from an away from the play foul, False otherwise.

is_flagrant_ft

returns True if free throw is from a flagrant foul, False otherwise.

is_ft_1_of_1
is_ft_1_of_2
is_ft_1_of_3
is_ft_1pt

returns True if free throw is a 1 point free throw, False otherwise Only used in g-league, starting in 2019-20 season

is_ft_2_of_2
is_ft_2_of_3
is_ft_2pt

returns True if free throw is a 2 point free throw, False otherwise Only used in g-league, starting in 2019-20 season

is_ft_3_of_3
is_ft_3pt

returns True if free throw is a 3 point free throw, False otherwise Only used in g-league, starting in 2019-20 season

is_made

returns True if shot was made, False otherwise

is_technical_ft

Jump Ball

class pbpstats.resources.enhanced_pbp.live.jump_ball.LiveJumpBall(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.jump_ball.JumpBall, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for jump ball events

action_type = 'jumpball'

Rebound

class pbpstats.resources.enhanced_pbp.live.rebound.LiveRebound(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.rebound.Rebound, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for rebound events

action_type = 'rebound'
is_placeholder

returns True if rebound is a placeholder event, False otherwise.

These are team rebounds on for example missed FT 1 of 2

missed_shot

returns FieldGoal or FreeThrow object for shot that was missed

Raises:EventOrderError: If rebound event is not immediately following a missed shot event.
oreb

returns True if rebound is an offensive rebound, False otherwise

Replay

class pbpstats.resources.enhanced_pbp.live.replay.LiveReplay(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.replay.Replay, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for replay events

action_type = 'replay'
overturn_ruling
ruling_stands
support_ruling

Start of Period

class pbpstats.resources.enhanced_pbp.live.start_of_period.LiveStartOfPeriod(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.start_of_period.StartOfPeriod, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for start of period events

action_type = 'period'
get_period_starters(file_directory=None, ignore_missing_starters=False)[source]

Gets player ids of players who started the period for each team

Parameters:
  • file_directory (str) – directory in which overrides subdirectory exists containing period starter overrides when period starters can’t be determined from parsing pbp events
  • ignore_missing_starters (bool) – when True won’t reaise missing starters exception
Returns:

dict with list of player ids for each team with players on the floor at start of period

Raises:

InvalidNumberOfStartersException: If all 5 players that start the period for a team can’t be determined.

sub_type = 'start'

Substitution

class pbpstats.resources.enhanced_pbp.live.substitution.LiveSubstitution(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.substitution.Substitution, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for Substitution events

action_type = 'substitution'
current_players

returns dict with list of player ids for each team with players on the floor following the sub

incoming_player_id

returns player id of player coming in to the game

outgoing_player_id

returns player id of player coming in to the game

Timeout

class pbpstats.resources.enhanced_pbp.live.timeout.LiveTimeout(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.timeout.Timeout, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for timeout events

action_type = 'timeout'

Turnover

class pbpstats.resources.enhanced_pbp.live.turnover.LiveTurnover(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.turnover.Turnover, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for Turnover events

action_type = 'turnover'
is_3_second_violation
is_bad_pass
is_bad_pass_out_of_bounds
is_kicked_ball
is_lane_violation
is_lost_ball
is_lost_ball_out_of_bounds
is_no_turnover
is_offensive_goaltending
is_shot_clock_violation
is_step_out_of_bounds
is_travel

Violation

class pbpstats.resources.enhanced_pbp.live.violation.LiveViolation(*args)[source]

Bases: pbpstats.resources.enhanced_pbp.violation.Violation, pbpstats.resources.enhanced_pbp.live.enhanced_pbp_item.LiveEnhancedPbpItem

Class for violation events

action_type = 'violation'
is_delay_of_game
is_double_lane_violation
is_goaltend_violation
is_jumpball_violation
is_kicked_ball_violation
is_lane_violation