Exemplo n.º 1
0
 def get_team_stats(self):
     series = get_team_stats('GSW', 2019)
     expected_indices = [
         'G', 'MP', 'FG', 'FGA', 'FG%', '3P', '3PA', '3P%', '2P', '2PA',
         '2P%', 'FT', 'FTA', 'FT%', 'ORB', 'DRB', 'TRB', 'AST', 'STL',
         'BLK', 'TOV', 'PF', 'PTS'
     ]
     self.assertCountEqual(list(series.index), expected_indices)
Exemplo n.º 2
0
def team_opp_stats(team, year, data_format):

    print("Saving into excel sheet... ")
    writer = ExcelWriter("./Excel-Sheets/%s-%d_OPP-STATS_%s.xlsx" % (team, year, data_format))
    team_df = get_team_stats(team, year, data_format).reset_index().transpose()
    team_df.to_excel(writer, sheet_name=team, startrow=0, startcol=0, index=False, header=True)

    writer.save()
Exemplo n.º 3
0
def insert_stats(year):
    team_dfs = []
    sheets = []

    writer = ExcelWriter("./Excel-Sheets/NBA-%d_PerGameStats.xlsx" % year)

    # for t, a in TEAM_TO_TEAM_ABBR.items():
    #     team_dfs.append(get_team_stats(a, year, 'PER_G
    #     AME'))

    for t, a in TEAM_TO_TEAM_ABBR.items():
        team_dfs.append(get_team_stats(a, year, 'PER_GAME').reset_index().transpose())
        sheets.append(t)

    for df, sheet in zip(team_dfs, sheets):
        df.to_excel(writer, sheet_name=sheet, startrow=0, startcol=0, index=False, header=False)

    writer.save()
Exemplo n.º 4
0
def user_input():
    team_or_player = input("What stats would you like to see: (1)Team or (2)Player ")

    if team_or_player == '1':
        user_team = input("What team would you like to view? ")
        user_season = int(input("Enter the desired season: "))

        user_stats = input("Enter the number for what stat you would like to see: \n1.) Roster List\n"
                           "2.) Team Stats\n"
                           "3.) Team Opponent Stats\n"
                           "4.) Roster Stats\n"
                           "5.) Misc Stats\n")

        print_or_excel = input("Would you like to save information in an excel sheet (Y/N)? ").upper()

        if user_stats == '1':

            if print_or_excel == 'Y':
                roster_list(user_team, user_season)
                print("Saved")

            elif print_or_excel == 'N':
                print(get_roster(user_team, user_season))

        elif user_stats == '2':
            data_format = input("Enter data format: (TOTAL | PER_GAME): ").upper()

            if print_or_excel == 'Y':
                team_stats(user_team, user_season, data_format)
                print(get_team_stats(user_team, user_season, data_format))

            elif print_or_excel == 'N':
                print(get_team_stats(user_team, user_season, data_format))

        elif user_stats == '3':
            data_format = input("Enter data format: (TOTAL | PER_GAME: ").upper()

            if print_or_excel == 'Y':
                team_opp_stats(user_team, user_season, data_format)
                print(get_opp_stats(user_team, user_season, data_format))

            elif print_or_excel == 'N' or 'n':
                print(get_opp_stats(user_team, user_season, data_format))

        elif user_stats == '4':
            user_playoffs = input("Would you like playoff roster stats? (Y/N) ")
            data_format = input("Enter data format: (TOTAL | PER_GAME): ").upper()
            playoffs = False

            if user_playoffs == 'Y':
                playoffs = True
            if print_or_excel == 'Y':
                roster_stats(user_team, user_season, data_format, playoffs)
                print(get_roster_stats(user_team, user_season, data_format, playoffs))
            elif print_or_excel == 'N':
                print(get_roster_stats(user_team, user_season, data_format, playoffs))

        elif user_stats == '5':
            if print_or_excel == 'Y':
                team_misc(user_team, user_season)
                print(get_team_misc(user_team, user_season))
            elif print_or_excel == 'N':
                print(get_team_misc(user_team, user_season))

    elif team_or_player == '2':
        user_player = input('What player do you like to view? ')
        print_or_excel = input("Save into excel sheet? (Y/N): ").upper()

        user_stats = input("Enter the number for what stat you would like to see: \n"
                           "1.) Player Stats\n"
                           "2.) Game Logs\n")
        user_playoffs = input("Playoff Stats? (Y/N): ").upper()

        if user_stats == '1':
            stat_type = input("Enter stat type: (PER_GAME | PER_MINUTE | PER_POSS | ADVANCED): ").upper()
            user_career = input("Career Stats? (Y/N): ").upper()

            if user_playoffs == 'Y':
                playoffs = True
            else:
                playoffs = False

            if user_career == 'Y':
                career = True
            else:
                career = False

            if print_or_excel == "Y":
                player_stats(user_player, stat_type, playoffs, career)
                print(get_stats(user_player, stat_type, playoffs, career))
            elif print_or_excel == "N":
                print(get_stats(user_player, stat_type, playoffs, career))

        elif user_stats == '2':
            user_start_date = input("Enter start date: (YYYY-MM-DD): ").upper()
            user_end_date = input("Enter end date: (YYYY-MM-DD): ")
            if user_playoffs == 'Y':
                playoffs = True
            else:
                playoffs = False

            if print_or_excel == "Y":
                player_game_logs(user_player, user_start_date, user_end_date, playoffs)
                print(get_game_logs(user_player, user_start_date, user_end_date, playoffs))
            elif print_or_excel == "N":
                print(get_game_logs(user_player, user_start_date, user_end_date, playoffs))
Exemplo n.º 5
0
from basketball_reference_scraper.teams import get_roster, get_team_stats, get_opp_stats, get_roster_stats, get_team_misc

df = get_roster('GSW', 2019)
print(df)

s = get_team_stats('GSW', 2019, data_format='PER_GAME')
print(s)

s = get_opp_stats('GSW', 2019, data_format='PER_GAME')
print(s)

s = get_roster_stats('GSW', 2019, data_format='PER_GAME', playoffs=False)
print(s)

s = get_team_misc('GSW', 2019)
print(s)

from basketball_reference_scraper.players import get_stats, get_game_logs

s = get_stats('Stephen Curry',
              stat_type='PER_GAME',
              playoffs=False,
              career=False)
print(s)

df = get_game_logs('LeBron James', '2010-01-19', '2014-01-20', playoffs=False)
print(df)

from basketball_reference_scraper.seasons import get_schedule, get_standings

s = get_schedule(2018, playoffs=False)