Exemplo n.º 1
0
 def get_opp_stats(self):
     series = get_opp_stats('GSW', 2019)
     expected_indices = [
         'OPP_G', 'OPP_MP', 'OPP_FG', 'OPP_FGA', 'OPP_FG%', 'OPP_3P',
         'OPP_3PA', 'OPP_3P%', 'OPP_2P', 'OPP_2PA', 'OPP_2P%', 'OPP_FT',
         'OPP_FTA', 'OPP_FT%', 'OPP_ORB', 'OPP_DRB', 'OPP_TRB', 'OPP_AST',
         'OPP_STL', 'OPP_BLK', 'OPP_TOV', 'OPP_PF', 'OPP_PTS'
     ]
     self.assertCountEqual(list(series.index), expected_indices)
Exemplo n.º 2
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.º 3
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)