James McCool commited on
Commit
3c69d02
·
1 Parent(s): f40b61d

Simplify ROO model loading and remove model choice radio button

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -48,8 +48,8 @@ bo3_player_stats = 'https://docs.google.com/spreadsheets/d/10MVGsAHJPUAdK9SJ28Zq
48
  bo5_player_stats = 'https://docs.google.com/spreadsheets/d/10MVGsAHJPUAdK9SJ28ZqjgBgV2xBJSXEka-s2pIxHHE/edit?pli=1#gid=0'
49
 
50
  @st.cache_data
51
- def load_roo_model(URL):
52
- sh = gc.open(URL)
53
  worksheet = sh.worksheet('ROO')
54
  raw_display = pd.DataFrame(worksheet.get_all_records())
55
  raw_display["Salary"] = raw_display["Salary"].replace("$", "", regex=True).astype(float)
@@ -68,7 +68,7 @@ def load_roo_model(URL):
68
  @st.cache_data
69
  def load_bo1_proj_model(URL):
70
  sh = gc.open_by_url(URL)
71
- worksheet = sh.get_worksheet(13)
72
  raw_display = pd.DataFrame(worksheet.get_all_records())
73
  raw_display.rename(columns={"Name": "Player"}, inplace = True)
74
  raw_display['Odds%'] = raw_display['Odds%'].str.replace('%', '').astype(float)/100
@@ -82,7 +82,7 @@ def load_bo1_proj_model(URL):
82
  @st.cache_data
83
  def load_bo3_proj_model(URL):
84
  sh = gc.open_by_url(URL)
85
- worksheet = sh.get_worksheet(14)
86
  raw_display = pd.DataFrame(worksheet.get_all_records())
87
  raw_display.rename(columns={"Name": "Player"}, inplace = True)
88
  raw_display['Odds%'] = raw_display['Odds%'].str.replace('%', '').astype(float)/100
@@ -96,7 +96,7 @@ def load_bo3_proj_model(URL):
96
  @st.cache_data
97
  def load_bo5_proj_model(URL):
98
  sh = gc.open_by_url(URL)
99
- worksheet = sh.get_worksheet(15)
100
  raw_display = pd.DataFrame(worksheet.get_all_records())
101
  raw_display.rename(columns={"Name": "Player"}, inplace = True)
102
  raw_display['Odds%'] = raw_display['Odds%'].str.replace('%', '').astype(float)/100
@@ -141,15 +141,9 @@ with tab2:
141
  # Clear values from *all* all in-memory and on-disk data caches:
142
  # i.e. clear values from both square and cube
143
  st.cache_data.clear()
144
- model_choice = st.radio("What table would you like to display?", ('Overall', 'Wins', 'Losses'), key='roo_table')
145
  pos_var1 = st.selectbox('View specific position?', options = ['All', 'TOP', 'JNG', 'MID', 'ADC', 'SUP'], key = 'roo_posvar')
146
  team_var1 = st.multiselect('View specific team?', options = hold_display['Team'].unique(), key = 'roo_teamvar')
147
- if model_choice == 'Overall':
148
- hold_display = load_roo_model(overall_table)
149
- elif model_choice == 'Wins':
150
- hold_display = load_roo_model(wins_table)
151
- elif model_choice == 'Losses':
152
- hold_display = load_roo_model(losses_table)
153
  display = hold_display.set_index('Player')
154
  if team_var1:
155
  display = display[display['Team'].isin(team_var1)]
 
48
  bo5_player_stats = 'https://docs.google.com/spreadsheets/d/10MVGsAHJPUAdK9SJ28ZqjgBgV2xBJSXEka-s2pIxHHE/edit?pli=1#gid=0'
49
 
50
  @st.cache_data
51
+ def load_roo_model():
52
+ sh = gc.open('https://docs.google.com/spreadsheets/d/10MVGsAHJPUAdK9SJ28ZqjgBgV2xBJSXEka-s2pIxHHE/edit?pli=1#gid=0')
53
  worksheet = sh.worksheet('ROO')
54
  raw_display = pd.DataFrame(worksheet.get_all_records())
55
  raw_display["Salary"] = raw_display["Salary"].replace("$", "", regex=True).astype(float)
 
68
  @st.cache_data
69
  def load_bo1_proj_model(URL):
70
  sh = gc.open_by_url(URL)
71
+ worksheet = sh.worksheet('Overall_BO1_Stats')
72
  raw_display = pd.DataFrame(worksheet.get_all_records())
73
  raw_display.rename(columns={"Name": "Player"}, inplace = True)
74
  raw_display['Odds%'] = raw_display['Odds%'].str.replace('%', '').astype(float)/100
 
82
  @st.cache_data
83
  def load_bo3_proj_model(URL):
84
  sh = gc.open_by_url(URL)
85
+ worksheet = sh.worksheet('Overall_BO3_Stats')
86
  raw_display = pd.DataFrame(worksheet.get_all_records())
87
  raw_display.rename(columns={"Name": "Player"}, inplace = True)
88
  raw_display['Odds%'] = raw_display['Odds%'].str.replace('%', '').astype(float)/100
 
96
  @st.cache_data
97
  def load_bo5_proj_model(URL):
98
  sh = gc.open_by_url(URL)
99
+ worksheet = sh.worksheet('Overall_BO5_Stats')
100
  raw_display = pd.DataFrame(worksheet.get_all_records())
101
  raw_display.rename(columns={"Name": "Player"}, inplace = True)
102
  raw_display['Odds%'] = raw_display['Odds%'].str.replace('%', '').astype(float)/100
 
141
  # Clear values from *all* all in-memory and on-disk data caches:
142
  # i.e. clear values from both square and cube
143
  st.cache_data.clear()
 
144
  pos_var1 = st.selectbox('View specific position?', options = ['All', 'TOP', 'JNG', 'MID', 'ADC', 'SUP'], key = 'roo_posvar')
145
  team_var1 = st.multiselect('View specific team?', options = hold_display['Team'].unique(), key = 'roo_teamvar')
146
+ hold_display = load_roo_model()
 
 
 
 
 
147
  display = hold_display.set_index('Player')
148
  if team_var1:
149
  display = display[display['Team'].isin(team_var1)]