예제 #1
0
def retrieve_all_nba_game_data(team, season):
    game_stats = [
        'assists', 'ats margin', 'ats streak', 'attendance', 'biggest lead',
        'blocks', 'conference', 'date', 'day', 'defensive rebounds',
        'division', 'dpa', 'dps', 'fast break points', 'field goals attempted',
        'field goals made', 'fouls', 'free throws attempted',
        'free throws made', 'game number', 'lead changes', 'line', 'losses',
        'margin', 'margin after the first', 'margin after the third',
        'margin at the half', 'matchup losses', 'matchup wins', 'minutes',
        'month', 'offensive rebounds', 'officials', 'opponents', 'ou margin',
        'ou streak', 'overtime', 'playoffs', 'points', 'points in the paint',
        'position', 'quarter scores', 'rebounds', 'rest', 'round', 'season',
        'seed', 'series game', 'series games', 'series losses', 'series wins',
        'site', 'site streak', 'steals', 'streak', 'team', 'team rebounds',
        'three pointers attempted', 'three pointers made', 'time of game',
        'time zone', 'times tied', 'total', 'turnovers', 'wins'
    ]
    season = str(season)
    team = str(team).capitalize()
    sdql = ','.join(game_stats) + '@season={season} and team={team}'.format(
        **locals())

    ret_d = dload.team_data_from_sdql(sdql, 'nba')
    if type(ret_d) == dict:
        ret_d = ret_d.values()[0]
    elif type(ret_d) == pd.DataFrame:
        if ret_d.empty:
            return None
    if store:
        dbase.write_team_data(ret_d)

    return ret_d
예제 #2
0
파일: nba.py 프로젝트: duffman8me/sports
def get_unique_teams(season=2014):
    if hasattr(season, '__iter__'):
        return pd.concat([get_unique_teams(ss) for ss in season], axis=1)
    else:        
        season = str(season)
        df = dload.team_data_from_sdql('Unique(team)@season={season}'.format(**locals()), 'nba')

        df = df.values()[0]
        df.columns = ['teams_{season}'.format(**locals())]

        return df
예제 #3
0
def get_unique_teams(season=2014):
    if hasattr(season, '__iter__'):
        return pd.concat([get_unique_teams(ss) for ss in season], axis=1)
    else:
        season = str(season)
        df = dload.team_data_from_sdql(
            'Unique(team)@season={season}'.format(**locals()), 'nba')

        df = df.values()[0]
        df.columns = ['teams_{season}'.format(**locals())]

        return df
예제 #4
0
파일: nba.py 프로젝트: duffman8me/sports
def retrieve_all_nba_game_data(team, season):
    game_stats = ['assists', 'ats margin',
                  'ats streak', 'attendance',
                  'biggest lead', 'blocks',
                  'conference', 'date', 'day',
                  'defensive rebounds', 'division',
                  'dpa', 'dps', 'fast break points',
                  'field goals attempted', 'field goals made',
                  'fouls', 'free throws attempted',
                  'free throws made', 'game number',
                  'lead changes', 'line', 'losses',
                  'margin', 'margin after the first',
                  'margin after the third',
                  'margin at the half', 'matchup losses',
                  'matchup wins', 'minutes', 'month',
                  'offensive rebounds', 'officials',
                  'opponents', 'ou margin', 'ou streak',
                  'overtime', 'playoffs', 'points',
                  'points in the paint', 'position',
                  'quarter scores', 'rebounds', 'rest',
                  'round', 'season', 'seed', 'series game',
                  'series games', 'series losses',
                  'series wins', 'site', 'site streak',
                  'steals', 'streak', 'team',
                  'team rebounds', 'three pointers attempted',
                  'three pointers made', 'time of game',
                  'time zone', 'times tied', 'total',
                  'turnovers', 'wins']
    season = str(season)
    team = str(team).capitalize()
    sdql = ','.join(game_stats) + '@season={season} and team={team}'.format(**locals())

    ret_d = dload.team_data_from_sdql(sdql, 'nba')
    if type(ret_d) == dict:
        ret_d = ret_d.values()[0]
    elif type(ret_d) == pd.DataFrame:
        if ret_d.empty:
            return None
    if store:
        dbase.write_team_data(ret_d)

    return ret_d