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)
def get_team_vs_team_stats(team_id, opponent_id=0): """Get team vs team stats.""" team_data_raw = team.TeamOpponentSplits(team_id) res_set = team_data_raw.json # return res_set['resultSets'][3] teams_data = res_set['resultSets'][3]['rowSet'] if opponent_id: opp_team = convert_team_id_to_name(opponent_id) match = [x for x in teams_data if x[-1] == opp_team] return dict(zip(tvt_keys, match[0])) else: return teams_data
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)
first = False else: summary.to_csv('players_summaries.csv', mode='a', header=False) # get year on year data by quarter team_yoy = team.TeamYearOverYearSplits(TEAMS["GSW"]["id"], season='2017-18', period="0") team_yoy.by_opponent().to_csv('year_over_year.csv', mode='a', header=True) for i in range(1,5): team_yoy = team.TeamYearOverYearSplits(TEAMS["GSW"]["id"], season='2017-18', period=str(i)) team_yoy.by_opponent().to_csv('year_over_year.csv', mode='a', header=False) # get stats with information about divisions # get stats with information about conferences opponents = team.TeamOpponentSplits(TEAMS["GSW"]["id"], season='2017-18', period="0") opponents.by_opponent().to_csv('opponents.csv', mode='a', header=True) opponents.by_conference().to_csv('opponents_by_conf.csv', mode='a', header=True) for i in range(1,5): opponents = team.TeamOpponentSplits(TEAMS["GSW"]["id"], season='2017-18', period=str(i)) opponents.by_opponent().to_csv('opponents.csv', mode='a', header=False) opponents.by_conference().to_csv('opponents_by_conf.csv', mode='a', header=False) # get stats with info about points allowed opponents = team.TeamPerformanceSplits(TEAMS["GSW"]["id"], season='2017-18', period="0") opponents.points_against().to_csv('points_against.csv', mode='a', header=True) for i in range(1,5): opponents = team.TeamPerformanceSplits(TEAMS["GSW"]["id"], season='2017-18', period=str(i)) opponents.points_against().to_csv('points_against.csv', mode='a', header=False)