예제 #1
0
def test():
    gid = '0041400122'
    assert game.BoxscoreScoring(gid)
    assert game.BoxscoreUsage(gid)
    assert game.BoxscoreMisc(gid)
    assert game.BoxscoreAdvanced(gid)
    assert game.BoxscoreFourFactors(gid)
    assert game.PlayByPlay(gid)
 def testAll(self):
     assert game.BoxscoreSummary(self.gameId)
     assert game.Boxscore(self.gameId)
     assert game.BoxscoreScoring(self.gameId)
     assert game.BoxscoreUsage(self.gameId)
     assert game.BoxscoreMisc(self.gameId)
     assert game.BoxscoreAdvanced(self.gameId)
     assert game.BoxscoreFourFactors(self.gameId)
     assert game.PlayByPlay(self.gameId)
     assert game.HustleStats(self.gameId)
    def testPlayByPlay(self):
        playbyplay = game.PlayByPlay(self.gameId)

        info = playbyplay.info()
        self.assertTrue((442, 12), info.shape)
        self.assertTrue((1 == info[1:2].PERIOD).all())

        availablevideo = playbyplay.available_video()
        self.assertTrue((1, 1), availablevideo.shape)
        self.assertTrue((2 == availablevideo[0:2].VIDEO_AVAILABLE_FLAG).all())
예제 #4
0
def test():
    gid = '0041400122'
    print(game.BoxscoreSummary(gid).line_score())
    assert game.BoxscoreSummary(gid)
    assert game.Boxscore(gid)
    assert game.BoxscoreScoring(gid)
    assert game.BoxscoreUsage(gid)
    assert game.BoxscoreMisc(gid)
    assert game.BoxscoreAdvanced(gid)
    assert game.BoxscoreFourFactors(gid)
    assert game.PlayByPlay(gid)
    assert game.HustleStats(gid)
예제 #5
0
from nba_py import game

pbp = game.PlayByPlay('0041400122')
print pbp.info()
bs = game.Boxscore('0041400122')
print bs.game_summary()
예제 #6
0
def playbyplay_to_mongo(game_id_list, pbp_db):

    for game_id in game_id_list:
        playbyplay = game.PlayByPlay(game_id).json
        collection = pbp_db[game_id]
        collection.insert(playbyplay)
예제 #7
0
    ]

    start_time = time.time()

    u_games = np.unique(game_list.index)

    play_by_play = pd.DataFrame()
    shot_chart_list = pd.DataFrame()
    lineup_list = pd.DataFrame(columns=('P1', 'P2', 'P3', 'P4', 'P5'))
    groupid_index = 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('-')