Beispiel #1
0
 def fetch_raw_data(self, player, season=None):
     self.player = player
     if season is None:
         season = make_season_str(determine_season_for_date(date.today()))
     log.debug("Pre network call")
     shot_chart = ShotChart(player_id=player.player_id,
                            season=str(season))
     log.debug("post network call")
     scdtl_dicts = dictify(shot_chart.json['resultSets'][0])
     self.raw_data = scdtl_dicts
Beispiel #2
0
import matplotlib.pyplot as plt
from multiprocessing import Pool
import numpy as np
for i in range(1100, 1231):
    # Generate games, they are 0001 to 1230
    print("ITERS", i)
    path = '/Users/tynanseltzer/ap216/project/pics/10/'
    gamestr = '002100'
    gamestr += str(i).zfill(4)
    # Home players
    summary = game.BoxscoreSummary(game_id=gamestr).game_summary()
    homeTeam = summary['HOME_TEAM_ID']
    awayTeam = summary['VISITOR_TEAM_ID']
    ids = game.Boxscore(game_id=gamestr).player_stats()['PLAYER_ID']
    # Go through players
    appended_data = []
    for an_id in ids:
        shot_df = ShotChart(player_id=an_id, game_id=gamestr, season='2010-11')
        shot_df = shot_df.shot_chart()
        appended_data.append(shot_df)
    shot_df = pd.concat(appended_data, axis=0)
    plt.scatter(shot_df.LOC_X, shot_df.LOC_Y)
    homePath = path + gamestr + ".jpg"
    plt.savefig(homePath,
                dpi=100,
                frameon='false',
                aspect='normal',
                bbox_inches='tight',
                pad_inches=0)
    plt.clf()
Beispiel #3
0
 path = '//Users/tynanseltzer/ap216/project/picseff/'
 gamestr = '002150'
 gamestr += str(i).zfill(4)
 # Home players
 summary = game.BoxscoreSummary(game_id=gamestr).game_summary()
 homeTeam = summary['HOME_TEAM_ID']
 awayTeam = summary['VISITOR_TEAM_ID']
 ids = game.Boxscore(game_id=gamestr).player_stats()['PLAYER_ID']
 homeIds = ids.where(
     game.Boxscore(
         game_id=gamestr).player_stats()['TEAM_ID'] == int(homeTeam))
 homeIds = homeIds.dropna().astype('int')
 # Go through players
 appended_data = []
 for an_id in homeIds:
     shot_df = ShotChart(player_id=an_id, game_id=gamestr, season='2015-16')
     shot_df = shot_df.shot_chart()
     appended_data.append(shot_df)
 shot_df = pd.concat(appended_data, axis=0)
 plt.scatter(shot_df.LOC_X, shot_df.LOC_Y)
 if int(homeTeam) in top:
     homePath = path + 'top/'
 else:
     homePath = path + 'bot/'
 homePath += gamestr + ".jpg"
 plt.savefig(homePath,
             dpi=100,
             frameon='false',
             aspect='normal',
             bbox_inches='tight',
             pad_inches=0)