Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -43,6 +43,16 @@ percentages_format = {'Shots': '{:.2%}', 'HDCF': '{:.2%}', 'Goals': '{:.2%}', 'A
|
|
43 |
def init_baselines():
|
44 |
sh = gcservice_account.open_by_url(NHL_data)
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
worksheet = sh.worksheet('Matchups')
|
47 |
raw_display = pd.DataFrame(worksheet.get_values())
|
48 |
raw_display.columns = raw_display.iloc[0]
|
@@ -67,19 +77,25 @@ def init_baselines():
|
|
67 |
overall_ms[data_cols] = overall_ms[data_cols].apply(pd.to_numeric, errors='coerce')
|
68 |
overall_ms = overall_ms.sort_values(by='Shots', ascending=False)
|
69 |
|
70 |
-
return matchups, overall_ms
|
71 |
|
72 |
def convert_df_to_csv(df):
|
73 |
return df.to_csv().encode('utf-8')
|
74 |
|
75 |
-
matchups, overall_ms = init_baselines()
|
76 |
|
77 |
col1, col2 = st.columns([1, 9])
|
78 |
with col1:
|
79 |
if st.button("Reset Data", key='reset1'):
|
80 |
st.cache_data.clear()
|
81 |
-
matchups, overall_ms = init_baselines()
|
82 |
split_var1 = st.radio("View matchups or line marketshares?", ('Slate Matchups', 'Line Marketshares'), key='split_var1')
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
with col2:
|
85 |
if split_var1 == 'Slate Matchups':
|
|
|
43 |
def init_baselines():
|
44 |
sh = gcservice_account.open_by_url(NHL_data)
|
45 |
|
46 |
+
worksheet = sh.worksheet('Player_Level_ROO')
|
47 |
+
raw_display = pd.DataFrame(worksheet.get_values())
|
48 |
+
raw_display.columns = raw_display.iloc[0]
|
49 |
+
raw_display = raw_display[1:]
|
50 |
+
raw_display = raw_display.reset_index(drop=True)
|
51 |
+
raw_display = raw_display[raw_display['Opp'] != ""]
|
52 |
+
team_frame = raw_display[['Team', 'Opp']]
|
53 |
+
team_list = team_frame['Team'].unique()
|
54 |
+
team_dict = dict(zip(team_frame['Team'], team_frame['Opp']))
|
55 |
+
|
56 |
worksheet = sh.worksheet('Matchups')
|
57 |
raw_display = pd.DataFrame(worksheet.get_values())
|
58 |
raw_display.columns = raw_display.iloc[0]
|
|
|
77 |
overall_ms[data_cols] = overall_ms[data_cols].apply(pd.to_numeric, errors='coerce')
|
78 |
overall_ms = overall_ms.sort_values(by='Shots', ascending=False)
|
79 |
|
80 |
+
return matchups, overall_ms, team_list, team_dict
|
81 |
|
82 |
def convert_df_to_csv(df):
|
83 |
return df.to_csv().encode('utf-8')
|
84 |
|
85 |
+
matchups, overall_ms, team_list, team_dict = init_baselines()
|
86 |
|
87 |
col1, col2 = st.columns([1, 9])
|
88 |
with col1:
|
89 |
if st.button("Reset Data", key='reset1'):
|
90 |
st.cache_data.clear()
|
91 |
+
matchups, overall_ms, team_list, team_dict = init_baselines()
|
92 |
split_var1 = st.radio("View matchups or line marketshares?", ('Slate Matchups', 'Line Marketshares'), key='split_var1')
|
93 |
+
if split_var1 == "Line Marketshares":
|
94 |
+
team_var = st.radio("View all teams or specific teams?", ('All Teams', 'Specific Teams'), key='team_var')
|
95 |
+
if team_var == "All Teams":
|
96 |
+
team_split = team_list
|
97 |
+
elif team_var == "Specific Teams":
|
98 |
+
team_split = st.multiselect('Which teams would you like to include in the tables?', options = team_list, key='team_var1')
|
99 |
|
100 |
with col2:
|
101 |
if split_var1 == 'Slate Matchups':
|