Exemple #1
0
def test():
    team_id = TEAMS['ATL']['id']
    player_id = get_player('Lebron', 'James')
    assert team.TeamList()
    assert team.TeamSummary(team_id)
    team_details = team.TeamDetails(team_id)
    assert team_details
    assert team_details.background()
    assert team_details.history()
    assert team.TeamCommonRoster(team_id)
    assert team.TeamGeneralSplits(team_id)
    assert team.TeamOpponentSplits(team_id)
    assert team.TeamLastNGamesSplits(team_id)
    assert team.TeamInGameSplits(team_id)
    assert team.TeamClutchSplits(team_id)
    assert team.TeamShootingSplits(team_id)
    assert team.TeamPerformanceSplits(team_id)
    assert team.TeamLineups(team_id)
    assert team.TeamPlayers(team_id)
    assert team.TeamPlayerOnOffDetail(team_id)
    assert team.TeamPlayerOnOffSummary(team_id)
    assert team.TeamGameLogs(team_id)
    assert team.TeamShotTracking(team_id)
    assert team.TeamReboundTracking(team_id)
    assert team.TeamPassTracking(team_id)
    assert team.TeamVsPlayer(team_id, player_id)
Exemple #2
0
def load_team_background():
  resDF = pd.DataFrame()
  i = 0
  for teamName in teamToIndex:
    print(teamName)
    teamId = TEAMS[teamName]["id"]
    backgroundDF = team.TeamDetails(teamId).background()
    socialDF = team.TeamDetails(teamId).social_sites()
    print(socialDF)
    resDF = pd.concat([resDF, backgroundDF], ignore_index=True, sort=False)
    facebook = socialDF.loc[socialDF['ACCOUNTTYPE'] == 'Facebook']['WEBSITE_LINK'].iloc[0]
    instagram = socialDF.loc[socialDF['ACCOUNTTYPE'] == 'Instagram']['WEBSITE_LINK'].iloc[0]
    twitter = socialDF.loc[socialDF['ACCOUNTTYPE'] == 'Twitter']['WEBSITE_LINK'].iloc[0]
    resDF.at[i, 'Facebook'] = facebook
    resDF.at[i, 'Instagram'] = instagram
    resDF.at[i, 'Twitter'] = twitter
    i = i + 1
    time.sleep(2)

  resDF.to_csv("data/team/team-background.csv", index=False)
Exemple #3
0
def nba_py(request):
    detail = team.TeamDetails(1610612752)
    positions = {
        'Center': 'C',
        'Guard': 'G',
        'Forward': 'F',
        'Center/Forward': 'C/F'
    }
    # print(list(mydict.keys())[list(mydict.values()).index(16)])
    hof = detail.hof()

    context = {'hof': hof}
    return render(request, 'yearly/nbainfo.html', context)
Exemple #4
0
def theroster(request, team_id):
    team_roster1 = team.TeamCommonRoster(team_id, season='2017-18')

    ###############################################################

    #Background
    detail = team.TeamDetails(team_id)

    background = detail.background()

    city = background['CITY'][0]
    nick = background['NICKNAME'][0]
    abbreviation = background['ABBREVIATION'][0]

    colorback = constants.TEAMS[abbreviation]['color']

    ################################################################

    players = []
    numbers = []
    ids = []
    positions = []

    team_roster = team_roster1.roster()

    # this gives us one name:
    #team_roster = team_roster.PLAYER[0]

    for i in range(len(team_roster)):
        players.append(team_roster['PLAYER'][i])
        numbers.append(team_roster['NUM'][i])
        positions.append(team_roster['POSITION'][i])
        ids.append(team_roster['PLAYER_ID'][i])
        #players.append(i)

    rosters = zip(players, numbers, positions, ids)

    context = {
        'team_roster': team_roster,
        'rosters': rosters,
        'team_roster': team_roster,
        'players': players,
        'city': city,
        'nick': nick,
        'abbreviation': abbreviation,
        'colorback': colorback
    }

    return render(request, 'yearly/teamroster.html', context)
Exemple #5
0
def teamwithid(request, team_id):
    detail = team.TeamDetails(team_id)
    playerifo = []

    ########################
    players = []
    years = []
    pos = []
    seasons = []

    ########################

    positions = {
        'Center': 'C',
        'Guard': 'G',
        'Forward': 'F',
        'Center/Forward': 'C/F'
    }
    # print(list(mydict.keys())[list(mydict.values()).index(16)])
    hof = detail.hof()

    for i in range(len(hof)):
        players.append(hof['PLAYER'][i])
        years.append(hof['YEAR'][i])
        pos.append(hof['POSITION'][i])
        seasons.append(hof['SEASONSWITHTEAM'][i])

    famers = zip(players, years, pos, seasons)

    #########################################################

    #Background
    background = detail.background()

    city = background['CITY'][0]
    nick = background['NICKNAME'][0]
    abbreviation = background['ABBREVIATION'][0]

    context = {
        'today': 'today',
        'hof': hof,
        'background': background,
        'city': city,
        'nick': nick,
        'famers': famers,
        'abbreviation': abbreviation
    }

    return render(request, 'yearly/nbainfo.html', context)
 def testAll(self):
     assert team.TeamList()
     assert team.TeamSummary(self.teamId)
     team_details = team.TeamDetails(self.teamId)
     assert team_details
     # assert team_details.background()
     # assert team_details.history()
     assert team.TeamCommonRoster(self.teamId)
     assert team.TeamGeneralSplits(self.teamId)
     assert team.TeamOpponentSplits(self.teamId)
     assert team.TeamLastNGamesSplits(self.teamId)
     assert team.TeamInGameSplits(self.teamId)
     assert team.TeamClutchSplits(self.teamId)
     assert team.TeamShootingSplits(self.teamId)
     assert team.TeamPerformanceSplits(self.teamId)
     assert team.TeamLineups(self.teamId)
     assert team.TeamPlayers(self.teamId)
     assert team.TeamPlayerOnOffDetail(self.teamId)
     assert team.TeamPlayerOnOffSummary(self.teamId)
     assert team.TeamGameLogs(self.teamId)
     assert team.TeamShotTracking(self.teamId)
     assert team.TeamReboundTracking(self.teamId)
     assert team.TeamPassTracking(self.teamId)
     assert team.TeamVsPlayer(self.teamId, self.playerId)
Exemple #7
0
def print_team_information(team_choice):
    # print(team_choice)
    try:
        team_id = team_ids[team_choice]
    except:
        print("Invalid team.")
        print()
        print()
        return
    # print(team_id)
    print('1. View Team Roster')
    print('2. View Team Coaches')
    print('3. View Championship History')
    print('4. View Hall of Fame History')
    print('5. View Retired Jerseys')
    print('6. View Season Totals for Team\'s Players')
    print('7. View Shooting Splits by Area')
    print('8. View Season Totals for 2017-18')
    print('9. Go back to main menu')

    team_info_choice = input("What information about " + team_choice + " would you like to view?\n")

    teamdetails = team.TeamDetails(team_id)

    if int(team_info_choice) == 1:
        teamcommonroster = team.TeamCommonRoster(team_id, season='2017-18')
        printer.pprint(teamcommonroster.roster())

    elif int(team_info_choice) == 2:
        teamcommonroster = team.TeamCommonRoster(team_id, season='2017-18')
        printer.pprint(teamcommonroster.coaches())

    elif int(team_info_choice) == 3:
        # teamdetails = team.TeamDetails(team_id)
        printer.pprint(teamdetails.awards_championships())

    elif int(team_info_choice) == 4:
        # teamdetails = team.TeamDetails(team_id)
        printer.pprint(teamdetails.hof())

    elif int(team_info_choice) == 5:
        # teamdetails == team.TeamDetails(team_id)
        printer.pprint(teamdetails.retired())

    elif int(team_info_choice) == 6:
        teamplayers = team.TeamPlayers(team_id, season='2017-18')
        printer.pprint(teamplayers.season_totals())
        # printer.pprint(teamdetails.social_sites())

    elif int(team_info_choice) == 7:
        shooting = team.TeamShootingSplits(team_id)
        printer.pprint(shooting.shot_areas())

    elif int(team_info_choice) == 8:
        sum = team.TeamSummary(team_id, season='2017-18')
        printer.pprint(sum.season_ranks())

    elif int(team_info_choice) == 9:
        return

    else:
        print("Invalid menu choice")