Пример #1
0
def get_team_lineup_vs_specific_team_stats(team_id=1610612751, opponent_id=0):
    """Get all lineups and stats vs specific team."""
    team_vs_opp_raw = team.TeamLineups(team_id, opponent_team_id=opponent_id)
    opp_vs_team_raw = team.TeamLineups(opponent_id, opponent_team_id=team_id)
    team_vs_opp = small_lineup_vs_team_stats(lineup_group_id_parser(team_vs_opp_raw.lineups()))
    opp_vs_team = small_lineup_vs_team_stats(lineup_group_id_parser(opp_vs_team_raw.lineups()))
    return {team_id: team_vs_opp, opponent_id: opp_vs_team}
Пример #2
0
def test():
    team_id = TEAMS['ATL']['id']
    player_id = get_player('Lebron', 'James')
    assert team.TeamList()
    assert team.TeamSummary(team_id)
    team_details = team.TeamDetails(team_id)
    assert team_details
    assert team_details.background()
    assert team_details.history()
    assert team.TeamCommonRoster(team_id)
    assert team.TeamGeneralSplits(team_id)
    assert team.TeamOpponentSplits(team_id)
    assert team.TeamLastNGamesSplits(team_id)
    assert team.TeamInGameSplits(team_id)
    assert team.TeamClutchSplits(team_id)
    assert team.TeamShootingSplits(team_id)
    assert team.TeamPerformanceSplits(team_id)
    assert team.TeamLineups(team_id)
    assert team.TeamPlayers(team_id)
    assert team.TeamPlayerOnOffDetail(team_id)
    assert team.TeamPlayerOnOffSummary(team_id)
    assert team.TeamGameLogs(team_id)
    assert team.TeamShotTracking(team_id)
    assert team.TeamReboundTracking(team_id)
    assert team.TeamPassTracking(team_id)
    assert team.TeamVsPlayer(team_id, player_id)
Пример #3
0
def get_lineups(team_id_lst, season='2016-17'):
    lst_of_dicts = []
    for i in team_id_lst:
        team_lineups = team.TeamLineups(team_id=i, season=season).lineups()
        for j in range(team_lineups.shape[0]):
            lineup_ids = team_lineups.iloc[j]['GROUP_ID']
            lineup_names = team_lineups.iloc[j]['GROUP_NAME']
            points_scored = float(team_lineups.iloc[j]['PTS'])
            points_allowed = points_scored - float(
                team_lineups.iloc[j]['PLUS_MINUS'])
            GP = float(team_lineups.iloc[j]['GP'])
            MIN = float(team_lineups.iloc[j]['MIN'])
            FGA = float(team_lineups.iloc[j]['FGA'])
            FTA = float(team_lineups.iloc[j]['FTA'])
            OREB = float(team_lineups.iloc[j]['OREB'])
            TOV = float(team_lineups.iloc[j]['TOV'])

            lst_of_dicts.append({
                'lineup_ids': lineup_ids,
                'lineup_names': lineup_names,
                'points_scored': (points_scored * GP),
                'points_allowed': (points_allowed * GP),
                'FGA_l': (FGA * GP),
                'FTA_l': (FTA * GP),
                'OREB_l': (OREB * GP),
                'TOV_l': (TOV * GP),
                'MIN_TOT': (MIN * GP)
            })

    lineups_df = pd.DataFrame(lst_of_dicts)
    return lineups_df
 def testAll(self):
     assert team.TeamList()
     assert team.TeamSummary(self.teamId)
     team_details = team.TeamDetails(self.teamId)
     assert team_details
     # assert team_details.background()
     # assert team_details.history()
     assert team.TeamCommonRoster(self.teamId)
     assert team.TeamGeneralSplits(self.teamId)
     assert team.TeamOpponentSplits(self.teamId)
     assert team.TeamLastNGamesSplits(self.teamId)
     assert team.TeamInGameSplits(self.teamId)
     assert team.TeamClutchSplits(self.teamId)
     assert team.TeamShootingSplits(self.teamId)
     assert team.TeamPerformanceSplits(self.teamId)
     assert team.TeamLineups(self.teamId)
     assert team.TeamPlayers(self.teamId)
     assert team.TeamPlayerOnOffDetail(self.teamId)
     assert team.TeamPlayerOnOffSummary(self.teamId)
     assert team.TeamGameLogs(self.teamId)
     assert team.TeamShotTracking(self.teamId)
     assert team.TeamReboundTracking(self.teamId)
     assert team.TeamPassTracking(self.teamId)
     assert team.TeamVsPlayer(self.teamId, self.playerId)
Пример #5
0
from sklearn import datasets
import pandas as pd
from nba_py import team

clips = team.TeamLineups(1610612746)

isBlakeGood = team.TeamVsPlayer(1610612746, 201933)

print(isBlakeGood.shot_distance_off_court().head(10),
      isBlakeGood.shot_distance_on_court().head(10))
Пример #6
0
    n_games_save = 123

    for i in range(u_games.shape[0]):
        gameid = u_games[i]
        pbp = game.PlayByPlay(gameid).info()

        pbp['Season_ID'] = seasonid

        play_by_play = play_by_play.append(pbp[good_cols])

        teams = game_list.ix[gameid].Team_ID

        for teamid in teams:
            # Get the lineups for the game
            groupids = team.TeamLineups(teamid, gameid,
                                        season=season).lineups().GROUP_ID

            # Loop through Group IDs
            for groupid in groupids:
                group_str = groupid.replace(' ', '').split('-')
                lineup_list.loc[groupid_index] = group_str

                # Shot Chart Detail
                shotchart = player.PlayerShotChartLineupDetail(
                    gameid, groupid, season=season).overall()
                shotchart = shotchart[shot_cols]
                shotchart['GROUP_ID'] = groupid_index

                shot_chart_list = shot_chart_list.append(shotchart)

                groupid_index += 1