Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -105,8 +105,8 @@ position_dict = {'All':'','F':'Forwards','D':'Defense'}
|
|
105 |
player_games_df = player_games_df.rename(columns={'Total Points_pp':'PP Points'})
|
106 |
|
107 |
stat_input_list = ['TOI', 'Goals', 'Total Assists',
|
108 |
-
'First Assists',
|
109 |
-
|
110 |
|
111 |
|
112 |
df_cum_stat_total = player_games_df.groupby(['player_id','Player','Position']).agg(
|
@@ -344,6 +344,27 @@ def server(input, output, session):
|
|
344 |
@render.plot(alt="A histogram")
|
345 |
def plot():
|
346 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
rookie = ''
|
348 |
if input.rookie_switch():
|
349 |
rookie = 'Rookie '
|
@@ -451,7 +472,7 @@ def server(input, output, session):
|
|
451 |
|
452 |
|
453 |
if per_game == False:
|
454 |
-
fig.suptitle(rookie
|
455 |
ax.set_ylabel(stat,fontsize=20,color='black',**cgfont)
|
456 |
# else:
|
457 |
# fig.suptitle(stat+' Per Game, All Situations',y=.99,fontsize=48,color='black',**cgfont)
|
@@ -459,7 +480,7 @@ def server(input, output, session):
|
|
459 |
|
460 |
|
461 |
|
462 |
-
ax.set_title(str(current_season)[0:4]+'-'+str(start_season)[-4:]+' Season',y=1.01,fontsize=
|
463 |
ax.set_xlabel('Team Game',fontsize=20,color='black',**cgfont)
|
464 |
ax.tick_params(axis="x", labelsize=24,colors='black')
|
465 |
ax.set_facecolor('#ffffff')
|
@@ -469,7 +490,7 @@ def server(input, output, session):
|
|
469 |
|
470 |
fig.text(x=0.025,y=0.01,s="Created By: @TJStats",color='black', fontsize=20, horizontalalignment='left',**cgfont)
|
471 |
fig.text(x=0.975,y=0.01,s="Data: Natural Stat Trick",color='black', fontsize=20, horizontalalignment='right',**cgfont)
|
472 |
-
fig.text(x=.975,y=0.
|
473 |
|
474 |
ax.legend(prop=font,bbox_to_anchor=(0.01, 0.99),loc='upper left',framealpha=1,frameon=True)
|
475 |
plt.tight_layout()
|
|
|
105 |
player_games_df = player_games_df.rename(columns={'Total Points_pp':'PP Points'})
|
106 |
|
107 |
stat_input_list = ['TOI', 'Goals', 'Total Assists',
|
108 |
+
'First Assists', 'Total Points', 'PP Points','Shots', 'Hits',
|
109 |
+
'Shots Blocked']
|
110 |
|
111 |
|
112 |
df_cum_stat_total = player_games_df.groupby(['player_id','Player','Position']).agg(
|
|
|
344 |
@render.plot(alt="A histogram")
|
345 |
def plot():
|
346 |
|
347 |
+
|
348 |
+
team_select_list = [input.team_select()]
|
349 |
+
position_select_list = [input.position_select()]
|
350 |
+
|
351 |
+
|
352 |
+
|
353 |
+
if team_select_list[0] == 'All':
|
354 |
+
team_select_title = 'NHL '
|
355 |
+
else:
|
356 |
+
team_select_title = f'{team_abv_nst_dict[team_select_list[0]]} '
|
357 |
+
|
358 |
+
|
359 |
+
if position_select_list[0] == 'All':
|
360 |
+
position_select_title = ''
|
361 |
+
|
362 |
+
elif position_select_list[0] == 'F':
|
363 |
+
position_select_title = 'Forwards '
|
364 |
+
|
365 |
+
else:
|
366 |
+
position_select_title = 'Defense '
|
367 |
+
|
368 |
rookie = ''
|
369 |
if input.rookie_switch():
|
370 |
rookie = 'Rookie '
|
|
|
472 |
|
473 |
|
474 |
if per_game == False:
|
475 |
+
fig.suptitle(f'{rookie}{team_select_title}{position_select_title}{stat} Race',y=.98,fontsize=32,color='black',**cgfont)
|
476 |
ax.set_ylabel(stat,fontsize=20,color='black',**cgfont)
|
477 |
# else:
|
478 |
# fig.suptitle(stat+' Per Game, All Situations',y=.99,fontsize=48,color='black',**cgfont)
|
|
|
480 |
|
481 |
|
482 |
|
483 |
+
ax.set_title(str(current_season)[0:4]+'-'+str(start_season)[-4:]+' Season',y=1.01,fontsize=18,color='black',**cgfont,x=0,ha='left')
|
484 |
ax.set_xlabel('Team Game',fontsize=20,color='black',**cgfont)
|
485 |
ax.tick_params(axis="x", labelsize=24,colors='black')
|
486 |
ax.set_facecolor('#ffffff')
|
|
|
490 |
|
491 |
fig.text(x=0.025,y=0.01,s="Created By: @TJStats",color='black', fontsize=20, horizontalalignment='left',**cgfont)
|
492 |
fig.text(x=0.975,y=0.01,s="Data: Natural Stat Trick",color='black', fontsize=20, horizontalalignment='right',**cgfont)
|
493 |
+
fig.text(x=.975,y=0.92,s='Date: '+input.date().strftime('%B %d, %Y'),color='black', fontsize=18, horizontalalignment='right',**cgfont)
|
494 |
|
495 |
ax.legend(prop=font,bbox_to_anchor=(0.01, 0.99),loc='upper left',framealpha=1,frameon=True)
|
496 |
plt.tight_layout()
|