Пример #1
0
 def play_off_picture(self,
                      idx_data,
                      league_id=enums.LeagueID.Default,
                      season_id=enums.Season.Default):
     """
     Get information on how current playoff matchups and conference standings are.
 
     :param idx_data: the index to retrieve data from json.
     :type idx_data: int
     :param league_id: league to filter for.
     :type league_id: nba.enums.LeagueID
     :param season_id: Season for which to get stat leaders.
     :type season_id: nba.enums.Season
     :returns: A view of playoff or standings, as show in idx_data table breakdown below.
     :rtype: DataFrame
 
     ========   =======================   ==================================================================
     idx_data           Name                                   Description
     ========   =======================   ==================================================================
         0       EastConfPlayoffPicture    Breakdown of how East Conference playoff matchups currently look.
         1       WestConfPlayoffPicture    Breakdown of how West Conference playoff matchups currently look.
         2       EastConfStandings         Current standing for East Conference.
         3       WestConfStandings         Current standing for West Conference.
         4       EastConfRemainingGames    Breakdown of games remaining in East Conference.
         5       WestConfRemainingGames    Breakdown of games remaining in East Conference.
     ========   =======================   ==================================================================
 
     """
     params = clean_locals(locals())
     endpoint = "playoffpicture"
     r = self.request(endpoint, params)
     df = self.process_response(r, idx_data, "resultSets")
     return df
Пример #2
0
 def team_roster(self, team_id, idx_data, season=enums.Season.Default):
     """
     Get team roster breakdown.
 
     :param team_id: id of the team whose roster to retrieve
     :type team_id: int
     :param idx_data: the index to retrieve data from json.
     :type idx_data: int
     :param season: season for which we require data.
     :type season: str('%Y-%y')
     :returns: roster breakdown of player details.
     :rtype: Dataframe
     
     ========   ==================   ====================================================================
     idx_data         Name                             Description
     ========   ==================   ====================================================================
         0       Players              Players roster.
         1       Coaches              Coaching staff roster.
     ========   ==================   ====================================================================
 
     """
     params = clean_locals(locals())
     endpoint = "commonteamroster"
     r = self.request(endpoint, params)
     df = self.process_response(r, idx_data, "resultSets")
     return df
Пример #3
0
 def other_leaders(
     self,
     idx_data,
     league_id=enums.LeagueID.Default,
     stat_type=enums.StatType.Default,
     season=enums.Season.Default,
     season_type=enums.SeasonType.Default,
     player_or_team=enums.PlayerOrTeam.Default,
     game_scope=enums.GameScope.Default,
     player_scope=enums.PlayerScope.Default,
 ):
     """
    Get top 5 players/teams by a particular stat type.
 
     :param idx_data: the index to retrieve data from json.
     :type idx_data: int
     :param league_id: league to filter for.
     :type league_id: nba.enums.LeagueID
     :param stat_type: Stat to sort leaders table by.
     :type stat_type: nba.enums.StatType
     :param season: Season for which to get stat leaders.
     :type season: nba.enums.Season
     :param season_type: Regular Season or Playoffs.
     :type season_type: nba.enums.SeasonType
     :param player_or_team: whether to get individual players or by team.
     :type player_or_team: nba.enums.PlayerOrTeam
     :param game_scope: what games to include in the data.
     :type game_scope: nba.enums.GameScope
     :param player_scope: filter by rookies only or all players
     :type player_scope: nba.enums.PlayerScope
     :returns: top 5 players for given stat type, as defined below by idx_data.
     :rtype: DataFrame
 
     ========   ===============   ==================================================================
     idx_data        Name                                   Description
     ========   ===============   ==================================================================
         0       HomePageStat1     Traditional=PTS, Advanced=OFF_RATING, Tracking=DIST_MILES
         1       HomePageStat2     Traditional=REB, Advanced=DEF_RATING, Tracking=AST_POINTS_CREATED
         2       HomePageStat3     Traditional=AST, Advanced=NET_RATING, Tracking=DRIVES
         3       HomePageStat4     Traditional=STL, Advanced=PIE, Tracking=NUM_TOUCHES
         4       HomePageStat5     Traditional=FG_PCT, Advanced=REB_PCT, Tracking=POST_TOUCHES
         5       HomePageStat6     Traditional=FT_PCT, Advanced=AST_PCT, Tracking=REB_CONTEST
         6       HomePageStat7     Traditional=FG3_PCT, Advanced=TS_PCT, Tracking=CATCH_SHOOT_PTS
         7       HomePageStat8     Traditional=BLK, Advanced=EFG_PCT, Tracking=PULL_UP_PTS
     ========   ===============   ==================================================================
 
     """
     params = clean_locals(locals())
     endpoint = "homepagev2"
     r = self.request(endpoint, params)
     df = self.process_response(r, idx_data, "resultSets")
     return df
Пример #4
0
 def summary(
     self,
     game_id,
     idx_data,
     start_period=enums.StartPeriod.Default,
     end_period=enums.EndPeriod.Default,
     start_range=enums.StartRange.Default,
     end_range=enums.EndRange.Default,
     range_type=enums.RangeType.Default,
 ):
     """
     Get high level game summary stats for a given game.
 
     :param game_id: id for the game to get data for.
     :type game_id: str
     :param idx_data: the index to retrieve data from json.
     :type idx_data: int
     :param start_period: filter starting quarter to retrieve data for.
     :type start_period: nba.nba.bin.enums.StartPeriod
     :param end_period: filter upper quarter cutoff for data.
     :type end_period: nba.nba.bin.enums.EndPeriod
     :param start_range: mandatory in url build, appear to have no effect.
     :type start_range: nba.nba.bin.enums.StartRange
     :param end_range: mandatory in url build, appear to have no effect.
     :type end_range: nba.nba.bin.enums.EndRange
     :param range_type: mandatory in url build, appear to have no effect.
     :type range_type: nba.nba.bin.enums.RangeType
     :returns: high level game information, as defined below by idx_data table below.
     :rtype: Dataframe
 
     ========   ================   ==================================================
     idx_data       Name                             Description
     ========   ================   ==================================================
         0       GameSummary       High level overview of game information.
         1       OtherStats        Other high level game stats.
         2       Officials         Officials names and id's.
         3       InactivePlayers   Players not on roster for game.
         4       GameInfo          Date, attendance, time.
         5       LineScore         Scores by period.
         6       LastMeeting       Most recent meeting score and game info.
         7       SeasonSeries      Series results so far this season.
         8       AvailableVideo    Availability by video type.
     ========   ================   ==================================================
 
     """
     params = clean_locals(locals())
     endpoint = "boxscoresummaryv2"
     r = self.request(endpoint, params)
     df = self.process_response(r, idx_data, "resultSets")
     return df
Пример #5
0
 def history(self, league_id=enums.LeagueID.Default):
     """
     Breakdown of pick number and player data for historical drafts.
 
     :param league_id: define league to look at, nba.
     :type league_id: nba.enums.LeagueID
     :returns: Player pick numbers for historic drafts.
     :rtype: Dataframe
 
     """
     params = clean_locals(locals())
     endpoint = "drafthistory"
     r = self.request(endpoint, params)
     df = self.process_response(r, 0, "resultSets")
     return df
Пример #6
0
 def player_info(self, player_id):
     """
     Get detailed information for a player.
     
     :param player_id: id of player to get information for.
     :type player_id: int
     :returns: detailed player information.
     :rtype: Dataframe
     
     """
     params = clean_locals(locals())
     endpoint = "commonplayerinfo"
     r = self.request(endpoint, params)
     df = self.process_response(r, 0, "resultSets")
     return df
Пример #7
0
 def leaders_tiles(
     self,
     idx_data,
     league_id=enums.LeagueID.Default,
     stat=enums.Stat.Default,
     season=enums.Season.Default,
     season_type=enums.SeasonType.Default,
     player_or_team=enums.PlayerOrTeam.Default,
     game_scope=enums.GameScope.Default,
     player_scope=enums.PlayerScope.Default,
 ):
     """
     Get top 5 players/teams by a particular stat.
 
     :param idx_data: the index to retrieve data from json.
     :type idx_data: int
     :param league_id: league to filter for.
     :type league_id: nba.enums.LeagueID
     :param stat: Stat to sort leaders table by.
     :type stat: nba.enums.Stat
     :param season: Season for which to get stat leaders.
     :type season: nba.enums.Season
     :param season_type: Regular Season or Playoffs.
     :type season_type: nba.enums.SeasonType
     :param player_or_team: whether to get individual players or by team.
     :type player_or_team: nba.enums.PlayerOrTeam
     :param game_scope: what games to include in the data.
     :type game_scope: nba.enums.GameScope
     :param player_scope: filter by rookies only or all players
     :type player_scope: nba.enums.PlayerScope
     :returns: data for specified filters, as defined below by idx_data.
     :rtype: DataFrame
 
     ========   ==================   ====================================================
     idx_data        Name                         Description
     ========   ==================   ====================================================
         0       LeadersTiles         Top 5 players/teams by stat specified with id info.
         1       AllTimeSeasonHigh    Details of the all time high of the stat specified.
         2       LastSeasonHigh       Details of prior seasons high of stat specified.
         3       LastSeasonHigh       Details of prior seasons low of stat specified.
     ========   ==================   ====================================================
 
     """
     params = clean_locals(locals())
     endpoint = "leaderstiles"
     r = self.request(endpoint, params)
     df = self.process_response(r, idx_data, "resultSet")
     return df
Пример #8
0
 def leaders(
     self,
     idx_data,
     league_id=enums.LeagueID.Default,
     stat_category=enums.StatCategory.Default,
     season=enums.Season.Default,
     season_type=enums.SeasonType.Default,
     player_or_team=enums.PlayerOrTeam.Default,
     game_scope=enums.GameScope.Default,
     player_scope=enums.PlayerScope.Default,
 ):
     """
     Get top 5 players/teams by a particular stat.
 
     :param idx_data: the index to retrieve data from json.
     :type idx_data: int
     :param league_id: league to filter for.
     :type league_id: nba.enums.LeagueID
     :param stat_category: Stat to sort leaders table by.
     :type stat_category: nba.enums.StatCategory
     :param season: Season for which to get stat leaders.
     :type season: nba.enums.Season
     :param season_type: Regular Season or Playoffs.
     :type season_type: nba.enums.SeasonType
     :param player_or_team: whether to get individual players or by team.
     :type player_or_team: nba.enums.PlayerOrTeam
     :param game_scope: what games to include in the data.
     :type game_scope: nba.enums.GameScope
     :param player_scope: filter by rookies only or all players
     :type player_scope: nba.enums.PlayerScope
     :returns: data for specified filters, as defined below by idx_data.
     :rtype: DataFrame
 
     ========   ================   ==================================================
     idx_data        Name                         Description
     ========   ================   ==================================================
         0       HomePageLeaders   Top 5 players/teams by stat specified.
         1       LeagueAverage     League average of the stat specified.
         2       LeagueMax         League max of each stat column.
     ========   ================   ==================================================
 
     """
     params = clean_locals(locals())
     endpoint = "homepageleaders"
     r = self.request(endpoint, params)
     df = self.process_response(r, idx_data, "resultSets")
     return df
Пример #9
0
 def combine_stats(self, league_id=enums.LeagueID.Default, season_year="2016-17"):
     """
     Get combine results for a draft year.
 
     :param league_id: define league to look at, nba.
     :type league_id: nba.enums.LeagueID
     :param season_year: draft season.
     :type season_year: str('%Y-%y')
     :returns: Combine results by player.
     :rtype: Dataframe
 
     """
     params = clean_locals(locals())
     endpoint = "draftcombinestats"
     r = self.request(endpoint, params)
     df = self.process_response(r, 0, "resultSets")
     return df
Пример #10
0
 def get_moments(self, game_id, event_id):
     """
     ***Blocked Cannot Access***
     Get location moments for each player throughout a single game event.
 
     :param game_id: ID of the game to get location data from.
     :type game_id: str
     :param event_id: ID of specific game event.
     :type event_id: int
     :returns: location data for each snapshot in the event.
     :rtype: DataFrame
 
     """
     raise DeprecationWarning("This endpoint has been closed to public access")
     endpoint = "locations_getmoments"
     params = clean_locals(locals())
     r = self.request(endpoint, params)
     if len(r) > 0:
         try:
             headers = [
                 "TeamID",
                 "PlayerID",
                 "x_loc",
                 "y_loc",
                 "Radius",
                 "MomentID",
                 "GameClock",
                 "ShotClock",
                 "EventID",
             ]
             player_moments = []
             moments = r["moments"]
             for moment in moments:
                 for player in moment[5]:
                     player.extend(
                         (moments.index(moment), moment[2], moment[3], event_id)
                     )
                     player_moments.append(player)
             df = pd.DataFrame(player_moments, columns=headers)
         except:
             df = pd.DataFrame()
     else:
         df = pd.DataFrame()
     return df
Пример #11
0
 def usage(
     self,
     game_id,
     idx_data,
     start_period=enums.StartPeriod.Default,
     end_period=enums.EndPeriod.Default,
     start_range=enums.StartRange.Default,
     end_range=enums.EndRange.Default,
     range_type=enums.RangeType.Default,
 ):
     """
     Get usage stats for a given game.
 
     :param game_id: id for the game to get data for.
     :type game_id: str
     :param idx_data: the index to retrieve data from json.
     :type idx_data: int
     :param start_period: filter starting quarter to retrieve data for.
     :type start_period: nba.nba.bin.enums.StartPeriod
     :param end_period: filter upper quarter cutoff for data.
     :type end_period: nba.nba.bin.enums.EndPeriod
     :param start_range: mandatory in url build, appear to have no effect.
     :type start_range: nba.nba.bin.enums.StartRange
     :param end_range: mandatory in url build, appear to have no effect.
     :type end_range: nba.nba.bin.enums.EndRange
     :param range_type: mandatory in url build, appear to have no effect.
     :type range_type: nba.nba.bin.enums.RangeType
     :returns: Usage stats on a player/team, as defined below by idx_data.
     :rtype: Dataframe
 
     ========   ================   ==================================================
     idx_data       Name                            Description
     ========   ================   ==================================================
         0       sqlPlayersUsage   Usage stats on an individual player basis.
         1       sqlTeamsUsage     Usage stats on a team basis.
     ========   ================   ==================================================
 
 
     """
     params = clean_locals(locals())
     endpoint = "boxscoreusagev2"
     r = self.request(endpoint, params)
     df = self.process_response(r, idx_data, "resultSets")
     return df
Пример #12
0
 def play_off_series(self,
                     league_id=enums.LeagueID.Default,
                     season=enums.Season.Default):
     """
     Get playoff series match ups for a given season.
 
     :param league_id: league to retrieve data for.
     :type league_id: str
     :param season: Season for which we require data.
     :type season: str('%Y-%y')
     :returns: match up by home/away team id and series id.
     :rtype: Dataframe
 
     """
     params = clean_locals(locals())
     endpoint = "commonplayoffseries"
     r = self.request(endpoint, params)
     df = self.process_response(r, 0, "resultSets")
     return df
Пример #13
0
 def combine_player_anthropology(
     self, league_id=enums.LeagueID.Default, season_year="2016-17"
 ):
     """
     Detailed breakdown of players measurements and physical stats.
 
     :param league_id: define league to look at, nba.
     :type league_id: nba.enums.LeagueID
     :param season_year: draft season.
     :type season_year: str('%Y-%y')
     :returns: Measurements and physical information by player.
     :rtype: Dataframe
 
     """
     params = clean_locals(locals())
     endpoint = "draftcombineplayeranthro"
     r = self.request(endpoint, params)
     df = self.process_response(r, 0, "resultSets")
     return df
Пример #14
0
 def combine_stationary_shooting(
     self, league_id=enums.LeagueID.Default, season_year="2016-17"
 ):
     """
     Moving shooting scores broken down by movement type.
 
     :param league_id: define league to look at, nba.
     :type league_id: nba.enums.LeagueID
     :param season_year: draft season.
     :type season_year: str('%Y-%y')
     :returns: Movement shooting results by player.
     :rtype: Dataframe
 
     """
     params = clean_locals(locals())
     endpoint = "draftcombinenonstationaryshooting"
     r = self.request(endpoint, params)
     df = self.process_response(r, 0, "resultSets")
     return df
Пример #15
0
 def video_status(
     self,
     game_date=datetime.datetime.today().strftime("%Y-%m-%d"),
     league_id=enums.LeagueID.Default,
 ):
     """
     Breakdown of which games are available on video on a given date.
 
     :param game_date: date to check.
     :type game_date: str('%Y-%m-%d')
     :param league_id: league to filter for.
     :type league_id: nba.enums.LeagueID
     :returns: games on the given date and whether they are available on video.
     :rtype: DataFrame
 
     """
     params = clean_locals(locals())
     endpoint = "videoStatus"
     r = self.request(endpoint, params)
     df = self.process_response(r, 0, "resultSets")
     return df
Пример #16
0
 def scoreboard(
     self, game_date, idx_data, day_off_set=0, league_id=enums.LeagueID.Default
 ):
     """
     Get the scoreboard and game data from a give date/date with offset.
 
     :param game_date: reference date to get data for.
     :type game_date: str('%Y-%m-%d')
     :param idx_data: the index to retrieve data from json.
     :type idx_data: int
     :param day_off_set: Number days prior to GameDate to get data for.
     :type day_off_set: int
     :param league_id: league to retrieve data for.
     :type league_id: str
     :returns:
     :rtype: DataFrame
 
     ========   =======================   ======================================================
     idx_data           Name                                  Description
     ========   =======================   ======================================================
         0       GameHeader                Overview of games returned.
         1       LineScore                 Score by period on a team basis and some basic stats.
         2       SeriesStandings           Season series current standing.
         3       LastMeeting               Last game info id, time, and scores
         4       EastConfStandingsByDay    Full standings for the Eastern Conference.
         5       WestConfStandingsByDay    Full standings for the Eastern Conference.
         6       Available                 Whether video is available for each game.
         7       TeamLeaders               Top players for each team by basic stats.
         8       TicketLinks               Links to buy tickets.
         9       WinProbability            Probability of team winning, often empty.
     ========   =======================   ======================================================
 
     """
     params = clean_locals(locals())
     endpoint = "scoreboardV2"
     r = self.request(endpoint, params, referer="scores")
     df = self.process_response(r, idx_data, "resultSets")
     return df
Пример #17
0
 def all_players(
     self,
     league_id=enums.LeagueID.Default,
     season=enums.Season.Default,
     is_only_current_season=1,
 ):
     """
     Get individual player details.
     
     :param league_id: league to retrieve data for.
     :type league_id: str
     :param season: Season for which we require data.
     :type season: str('%Y-%y')
     :param is_only_current_season: define whether to only get players on a roster in current season.
     :type is_only_current_season: bool(1|0)
     :returns: player information.
     :rtype: Dataframe
     
     """
     params = clean_locals(locals())
     endpoint = "commonallplayers"
     r = self.request(endpoint, params)
     df = self.process_response(r, 0, "resultSets")
     return df