Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -440,7 +440,7 @@ def server(input, output, session):
|
|
440 |
#test.loc[name == test.Player].reset_index().TOI[0]/1.5
|
441 |
min_time = min(math.floor(summary_2023.loc[player_id == summary_2023.player_id].reset_index().TOI[0]/100)*100,summary_2023.GP.max()*10)
|
442 |
# min_time = min(math.floor(test.loc[name == test.Player].reset_index().TOI[0]/100)*100,test.GP.max()*10)
|
443 |
-
test_filter = summary_2023[(summary_2023.TOI >= min_time)&(summary_2023.pos == summary_2023.loc[
|
444 |
test_filter['Goals/GP'] = test_filter['Goals']/test_filter['GP']
|
445 |
test_filter['Total Assists/GP'] = test_filter['Assists']/test_filter['GP']
|
446 |
test_filter['Total Points/GP'] = test_filter['Total_Points']/test_filter['GP']
|
@@ -474,8 +474,8 @@ def server(input, output, session):
|
|
474 |
test_filter['iSCF Z-Score'] = (test_filter['iSCF/60']-test_filter['iSCF/60'].mean())/test_filter['iSCF/60'].std()
|
475 |
test_filter['First Assists Z-Score'] = (test_filter['First Assists/60']-test_filter['First Assists/60'].mean())/test_filter['First Assists/60'].std()
|
476 |
test_filter['P Z-Score'] = (test_filter['Total Points/60']-test_filter['Total Points/60'].mean())/test_filter['Total Points/60'].std()
|
477 |
-
values_1 = test_filter.loc[
|
478 |
-
values_2 = test_filter.loc[
|
479 |
categories = [i[:-11]+'/GP' for i in test_filter.columns[-14:-7]]
|
480 |
|
481 |
#categories = [*categories]
|
@@ -500,12 +500,12 @@ def server(input, output, session):
|
|
500 |
players_stats_all_on_filter['OZ Start% Z-Score'] = (players_stats_all_on_filter['OZ Start%']-players_stats_all_on_filter['OZ Start%'].mean())/players_stats_all_on_filter['OZ Start%'].std()
|
501 |
categories_on = [i[:-8]+'/60' for i in players_stats_all_on_filter.columns[-5:]]
|
502 |
categories_on = ['GF/60', 'xGF/60', 'CF/60', 'oiSH', 'OZ Start%']
|
503 |
-
player_on = list(np.around(players_stats_all_on_filter.loc[
|
504 |
categories_1 = [i[:-8]+'/GP' for i in test_filter.columns[-14:-7]]
|
505 |
categories_2 = [i[:-8]+'/60' for i in test_filter.columns[-7:]]
|
506 |
categories = categories_1+categories_2
|
507 |
categories[12] = '1A/60'
|
508 |
-
player = list(np.around(test_filter.loc[
|
509 |
|
510 |
# color_scheme = []
|
511 |
# for i in player:
|
@@ -523,8 +523,8 @@ def server(input, output, session):
|
|
523 |
# color_scheme.append('#FBBC04')
|
524 |
|
525 |
|
526 |
-
goals_above_expected = test_filter.loc[
|
527 |
-
goals_above_expected = test_filter.loc[
|
528 |
|
529 |
# color_scheme_on= []
|
530 |
# for i in player_on:
|
@@ -552,12 +552,12 @@ def server(input, output, session):
|
|
552 |
color_scheme_on = [colormap_new(norm_new(x)) for x in player_on]
|
553 |
|
554 |
players_stats_all_on_filter = players_stats_all_on_filter.rename(columns={'On-Ice SH%':'oiSH%','Off.\xa0Zone Start %':'OZ Start%'})
|
555 |
-
values_on = players_stats_all_on_filter.loc[
|
556 |
position_player = summary_2023_one['pos'].reset_index().pos[0]
|
557 |
-
rank_1 = list(test_filter[values_1.index].rank(method='min',ascending=False).loc[
|
558 |
-
rank_2 = list(test_filter[values_2.index].rank(method='min',ascending=False).loc[
|
559 |
-
rank_3 = list(players_stats_all_on_filter[values_on.index].rank(method='min',ascending=False).loc[
|
560 |
-
#rank_3 = rank_3 + list(players_stats_all_on_filter[values_on.index].rank(method='first',ascending=True).loc[
|
561 |
|
562 |
values_on = [float(x) for x in values_on]
|
563 |
|
|
|
440 |
#test.loc[name == test.Player].reset_index().TOI[0]/1.5
|
441 |
min_time = min(math.floor(summary_2023.loc[player_id == summary_2023.player_id].reset_index().TOI[0]/100)*100,summary_2023.GP.max()*10)
|
442 |
# min_time = min(math.floor(test.loc[name == test.Player].reset_index().TOI[0]/100)*100,test.GP.max()*10)
|
443 |
+
test_filter = summary_2023[(summary_2023.TOI >= min_time)&(summary_2023.pos == summary_2023.loc[player_id == summary_2023.player_id].reset_index().pos[0])]
|
444 |
test_filter['Goals/GP'] = test_filter['Goals']/test_filter['GP']
|
445 |
test_filter['Total Assists/GP'] = test_filter['Assists']/test_filter['GP']
|
446 |
test_filter['Total Points/GP'] = test_filter['Total_Points']/test_filter['GP']
|
|
|
474 |
test_filter['iSCF Z-Score'] = (test_filter['iSCF/60']-test_filter['iSCF/60'].mean())/test_filter['iSCF/60'].std()
|
475 |
test_filter['First Assists Z-Score'] = (test_filter['First Assists/60']-test_filter['First Assists/60'].mean())/test_filter['First Assists/60'].std()
|
476 |
test_filter['P Z-Score'] = (test_filter['Total Points/60']-test_filter['Total Points/60'].mean())/test_filter['Total Points/60'].std()
|
477 |
+
values_1 = test_filter.loc[player_id == test_filter.player_id][['Goals/GP','Total Assists/GP','Total Points/GP','PP Points/GP','Shots/GP','Hits/GP','Shots Blocked/GP']].reset_index(drop=True).loc[0]
|
478 |
+
values_2 = test_filter.loc[player_id == test_filter.player_id][['ixG/60','Goals/60','G-xG/60','iCF/60','iSCF/60','First Assists/60','Total Points/60']].reset_index(drop=True).loc[0]
|
479 |
categories = [i[:-11]+'/GP' for i in test_filter.columns[-14:-7]]
|
480 |
|
481 |
#categories = [*categories]
|
|
|
500 |
players_stats_all_on_filter['OZ Start% Z-Score'] = (players_stats_all_on_filter['OZ Start%']-players_stats_all_on_filter['OZ Start%'].mean())/players_stats_all_on_filter['OZ Start%'].std()
|
501 |
categories_on = [i[:-8]+'/60' for i in players_stats_all_on_filter.columns[-5:]]
|
502 |
categories_on = ['GF/60', 'xGF/60', 'CF/60', 'oiSH', 'OZ Start%']
|
503 |
+
player_on = list(np.around(players_stats_all_on_filter.loc[player_id == test_filter.player_id][players_stats_all_on_filter.columns[-5:]].values.flatten().tolist(),2))
|
504 |
categories_1 = [i[:-8]+'/GP' for i in test_filter.columns[-14:-7]]
|
505 |
categories_2 = [i[:-8]+'/60' for i in test_filter.columns[-7:]]
|
506 |
categories = categories_1+categories_2
|
507 |
categories[12] = '1A/60'
|
508 |
+
player = list(np.around(test_filter.loc[player_id == test_filter.player_id][test_filter.columns[-14:]].values.flatten().tolist(),2))
|
509 |
|
510 |
# color_scheme = []
|
511 |
# for i in player:
|
|
|
523 |
# color_scheme.append('#FBBC04')
|
524 |
|
525 |
|
526 |
+
goals_above_expected = test_filter.loc[player_id == test_filter.player_id]['Goals'] - test_filter.loc[player_id == test_filter.player_id]['ixG']
|
527 |
+
goals_above_expected = test_filter.loc[player_id == test_filter.player_id]['Goals'] - test_filter.loc[player_id == test_filter.player_id]['ixG']
|
528 |
|
529 |
# color_scheme_on= []
|
530 |
# for i in player_on:
|
|
|
552 |
color_scheme_on = [colormap_new(norm_new(x)) for x in player_on]
|
553 |
|
554 |
players_stats_all_on_filter = players_stats_all_on_filter.rename(columns={'On-Ice SH%':'oiSH%','Off.\xa0Zone Start %':'OZ Start%'})
|
555 |
+
values_on = players_stats_all_on_filter.loc[player_id == test_filter.player_id][['GF/60', 'xGF/60', 'CF/60', 'oiSH', 'OZ Start%']].reset_index(drop=True).loc[0]
|
556 |
position_player = summary_2023_one['pos'].reset_index().pos[0]
|
557 |
+
rank_1 = list(test_filter[values_1.index].rank(method='min',ascending=False).loc[player_id == test_filter.player_id].reset_index(drop=True).astype(int).iloc[0])
|
558 |
+
rank_2 = list(test_filter[values_2.index].rank(method='min',ascending=False).loc[player_id == test_filter.player_id].reset_index(drop=True).astype(int).iloc[0])
|
559 |
+
rank_3 = list(players_stats_all_on_filter[values_on.index].rank(method='min',ascending=False).loc[player_id == test_filter.player_id].reset_index(drop=True).astype(int).iloc[0][categories_on])
|
560 |
+
#rank_3 = rank_3 + list(players_stats_all_on_filter[values_on.index].rank(method='first',ascending=True).loc[player_id == test.player_id].reset_index(drop=False).astype(int).iloc[0][categories_on[3:5]])
|
561 |
|
562 |
values_on = [float(x) for x in values_on]
|
563 |
|