def specific_shot_stats(shot_type='Jump Shot', players=['Felton'], team='NYK', s_date='10000101', f_date='21001231', path='D:\Gal\Work\Results'): ''' ''' actions_per_game = tf.relevant_actions(team, path, s_date=s_date, f_date=f_date) res = [] for actions in actions_per_game: this_game = [0, 0] for a in actions: for p in players: if a.player == p and type(a) is c.Shot: if shot_type == a.kind: this_game[0] += 1 if a.made: this_game[1] += 1 res.append(this_game) return res
def shooting_stats_over_games(players=['Felton'], team='NYK', s_date='10000101', f_date='21001231', path='D:\Gal\Work\Results'): '''The function of dates nedd to added ''' actions_per_game = tf.relevant_actions(team, path, s_date=s_date, f_date=f_date) dic = {} for actions in actions_per_game: for a in actions: for p in players: if a.player == p and type(a) is c.Shot: shot_kind = a.kind if not dic.has_key(shot_kind): dic[shot_kind] = [0, 0] dic[shot_kind][0] += 1 if a.made: dic[a.kind][1] += 1 return dic
def time_raster(player, team='SAS', s_date='10000101', f_date='21001231', path='D:\Gal\Work\Results'): ''' plots a made time raster. Y axis is the number of the game. X axis is the minute in the game. ''' actions_per_game = tf.relevant_actions(team, path, s_date=s_date, f_date=f_date) time_list, played_games = [], [] i = 0 for actions in actions_per_game: i += 1 toc = time_on_court(player, actions) # print g, toc # DEBUG if len(toc) != 0: for t in toc: time_list += tf.break_it(t) played_games.append(i) return time_list, played_games
def actions_raster(players=['Duncan'], team='SAS', s_date='10000101', f_date='21001231', path='D:\Gal\Work\Results', action=c.Shot): ''' creates an actions raster. Y axis is the number of the game. X axis is the minute in the game. ''' actions_per_game = tf.relevant_actions(team, path, s_date=s_date, f_date=f_date) final_actions, played_games = [], [] i = 0 for actions in actions_per_game: i += 1 for a in actions: for p in players: if a.player == p and type(a) is action: final_actions.append(a.time) played_games.append(i) return final_actions, played_games
def shooting_other(shooting_player='Parker', over_player='Duncan', team='SAS', s_date='10000101', f_date='21001231', path='D:\Gal\Work\Results'): ''' This function calculates the shots of spesific player when other player is on the court ''' actions_per_game = tf.relevant_actions(team, path, s_date=s_date, f_date=f_date) dic = {} for actions in actions_per_game: for a in actions: if a.player == shooting_player and type(a) is c.Shot and action_when_on_court(a, over_player, actions): shot_kind = a.kind if not dic.has_key(shot_kind): dic[shot_kind] = [0, 0] dic[shot_kind][0] += 1 if a.made: dic[a.kind][1] += 1 return dic
def shots_made_raster(players=['Duncan'], team='SAS', s_date='10000101', f_date='21001231', path='D:\Gal\Work\Results'): ''' plots a made shots raster. Y axis is the number of the game. X axis is the minute in the game ''' actions_per_game = tf.relevant_actions(team, path, s_date=s_date, f_date=f_date) shots, played_games = [], [] i = 0 for actions in actions_per_game: i += 1 for a in actions: for p in players: if a.player == p and type(a) is c.Shot: if a.made: shots.append(a.time) played_games.append(i) return shots, played_games