def player(): if request.method == 'GET': return f"The URL /player is accessed directly. Try going to '/' to search for player" form_data = request.form name = form_data['player'] year = form_data['year'] name = name.title() try: stats = get_stats(name, 'PER_GAME', ask_matches=False) except: return render_template('error.html') pl = stats[[ 'SEASON', 'TEAM', 'PTS', 'TRB', 'AST', 'STL', 'BLK', 'FG%', '3P%' ]] cur_season = pl.loc[pl['SEASON'] == year] pic = get_player_headshot(name, ask_matches=False) return render_template('base.html', data=cur_season.to_html( classes='table table-striped', index=False, col_space=100, justify='match-parent'), name=name, pic=pic, year=year)
def show_final_results(mvp_candidates): print("---- MVP CANDIDATES ----") name = [] vote = [] for mvp_candidate in mvp_candidates: print(f"\t {mvp_candidate[0]}: {mvp_candidate[1]}") name.append(mvp_candidate[0]) vote.append(mvp_candidate[1]) print("----") plt.pie(vote, labels=name, startangle=90, shadow=True, autopct='%1.1f%%') url = get_player_headshot(name[0]) print(f"MVP {name[0]} Portrait: {url}") plt.title('MVP RESULTS!') plt.show()
''' Get individual players name - Player full name (e.g. 'LaMarcus Aldridge') stat_type - One of 'PER_GAME', 'PER_MINUTE', 'PER_POSS', 'ADVANCED' playoffs - Whether to return Playoff stats or not. One of True|False. Default value is False career - Whether to return career stats or not. One of True|False. Default value is False ''' coby = get_stats("Coby White", stat_type='ADVANCED', playoffs=False, career=False) coby.head(10) d = get_player_headshot('Coby White') d = get_shot_chart('2019-12-28', 'TOR', 'BOS') #Import college players from sportsreference.ncaab.roster import Player as pl player_ncaa = pl('kenyon-martin-1') #get available object variables dir(player_ncaa) player_ncaa.dataframe.iloc[-2, :] import glob import pandas as pd draft_files = glob.glob("*") len(draft_files)
def test_get_player_headshot(self): expected_url = 'https://d2cwpp38twqe55.cloudfront.net/req/202006192/images/players/bryanko01.jpg' url = get_player_headshot('Kobe Bryant') self.assertEqual(url, expected_url)
stat_type='BASIC') print(s) from basketball_reference_scraper.pbp import get_pbp s = get_pbp('2020-01-13', 'CHI', 'BOS') print(s) from basketball_reference_scraper.shot_charts import get_shot_chart s = get_shot_chart('2020-01-13', 'CHI', 'BOS') print(s) from basketball_reference_scraper.injury_report import get_injury_report s = get_injury_report() print(s) from basketball_reference_scraper.players import get_game_logs, get_player_headshot df = get_game_logs('Pau Gasol', '2010-01-12', '2010-01-20', playoffs=False) print(df) url = get_player_headshot('Kobe Bryant') print(url) from basketball_reference_scraper.drafts import get_draft_class df = get_draft_class(2003) print(df)