<jupyter_start><jupyter_text>This notebook demonstrates a game's data and analyse its various data<jupyter_code>%load_ext autoreload
%autoreload 2

from statsnba import Game, Api
import requests_cache
import pandas as pd
pd.options.display.max_columns = 999

requests_cache.install_cache('test_cache')
api = Api()
game_ids = api.GetSeasonGameIDs('2009-10', 'Regular Season')
game_ids
sample_game_id = game_ids[0]
sample_game = Game(sample_game_id)
sample_game
def matchup_to_df(matchups):
    lst = []
    for matchup in sample_game.Matchups:
        matchup_dict = {}
        _home_players = sorted([p.PlayerName for p in matchup.HomePlayers])
        _away_players = sorted([p.PlayerName for p in matchup.AwayPlayers])
        home_players = dict(zip(['h{}'.format(i) for i in range(5)], _home_players))
        away_players = dict(zip(['a{}'.format(i) for i in range(5)], _away_players))
        
        matchup_dict.update(home_players)
        matchup_dict.update(away_players)        
        home_boxscore = matchup.Boxscore.HomeTeamStats
        away_boxscore = matchup.Boxscore.AwayTeamStats
        
        matchup_dict.update({'home_{}'.format(k):v for k,v in home_boxscore.items()})
        matchup_dict.update({'away_{}'.format(k):v for k,v in away_boxscore.items()})
        lst.append(matchup_dict)
    return lst

df = pd.DataFrame(matchup_to_df(sample_game.Matchups))
print 'The first two rows of the matchups and their stats'
df.head(2)
print "Description of the various statistics"
df.describe()<jupyter_output>Description of the various statistics
{'fraction_non_alphanumeric': 0.10516252390057361, 'fraction_numerical': 0.008922880815806247, 'mean_word_length': 4.21594684385382, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '602390', 'license': 'MIT', 'n_tokens_mistral': 539, 'n_tokens_neox': 519, 'n_words': 118, 'path': 'docs/demo_matchups.ipynb', 'repo_name': 'ethanluoyc/statsnba-playbyplay', 'size': '1569'}