Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -231,26 +231,27 @@ with tab1:
|
|
| 231 |
min_var1 = st.slider("Is there a certain minutes range you want to view?", 0, 60, (0, 60), key='min_var1')
|
| 232 |
|
| 233 |
with col2:
|
|
|
|
| 234 |
if split_var1 == 'Season Logs':
|
| 235 |
display = st.container()
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
season_long_table = seasonlong_build(
|
| 243 |
season_long_table = season_long_table.set_index('Player')
|
| 244 |
display.dataframe(season_long_table.style.format(precision=2), height=750, use_container_width = True)
|
| 245 |
|
| 246 |
elif split_var1 == 'Gamelogs':
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
display = st.container()
|
| 255 |
|
| 256 |
bottom_menu = st.columns((4, 1, 1))
|
|
@@ -258,7 +259,7 @@ with tab1:
|
|
| 258 |
batch_size = st.selectbox("Page Size", options=[25, 50, 100])
|
| 259 |
with bottom_menu[1]:
|
| 260 |
total_pages = (
|
| 261 |
-
int(len(
|
| 262 |
)
|
| 263 |
current_page = st.number_input(
|
| 264 |
"Page", min_value=1, max_value=total_pages, step=1
|
|
@@ -267,7 +268,7 @@ with tab1:
|
|
| 267 |
st.markdown(f"Page **{current_page}** of **{total_pages}** ")
|
| 268 |
|
| 269 |
|
| 270 |
-
pages = split_frame(
|
| 271 |
# pages = pages.set_index('Player')
|
| 272 |
display.dataframe(data=pages[current_page - 1].style.format(precision=2), height=500, use_container_width=True)
|
| 273 |
|
|
@@ -308,32 +309,33 @@ with tab2:
|
|
| 308 |
min_var1_t2 = st.slider("Is there a certain minutes range you want to view?", 0, 60, (0, 60), key='min_var1_t2')
|
| 309 |
|
| 310 |
with col2:
|
|
|
|
| 311 |
if split_var1_t2 == 'Specific Teams':
|
| 312 |
display = st.container()
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
if corr_var == 'Fantasy':
|
| 320 |
-
corr_display = run_fantasy_corr(
|
| 321 |
elif corr_var == 'Minutes':
|
| 322 |
-
corr_display = run_min_corr(
|
| 323 |
display.dataframe(corr_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=1000, use_container_width = True)
|
| 324 |
|
| 325 |
elif split_var1_t2 == 'Specific Players':
|
| 326 |
display = st.container()
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
if corr_var == 'Fantasy':
|
| 334 |
-
corr_display = run_fantasy_corr(
|
| 335 |
elif corr_var == 'Minutes':
|
| 336 |
-
corr_display = run_min_corr(
|
| 337 |
display.dataframe(corr_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 338 |
|
| 339 |
with tab3:
|
|
@@ -366,17 +368,21 @@ with tab3:
|
|
| 366 |
min_var3 = st.slider("Is there a certain minutes range you want to view?", 0, 60, (0, 60), key='min_var3')
|
| 367 |
|
| 368 |
with col2:
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
|
|
|
|
|
|
|
|
|
| 372 |
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
gamelog_display =
|
|
|
|
| 380 |
display = st.container()
|
| 381 |
|
| 382 |
# pages = pages.set_index('Player')
|
|
|
|
| 231 |
min_var1 = st.slider("Is there a certain minutes range you want to view?", 0, 60, (0, 60), key='min_var1')
|
| 232 |
|
| 233 |
with col2:
|
| 234 |
+
working_data = gamelog_table
|
| 235 |
if split_var1 == 'Season Logs':
|
| 236 |
display = st.container()
|
| 237 |
+
working_data = working_data[working_data['Date'] >= low_date]
|
| 238 |
+
working_data = working_data[working_data['Date'] <= high_date]
|
| 239 |
+
working_data = working_data[working_data['Min'] >= min_var1[0]]
|
| 240 |
+
working_data = working_data[working_data['Min'] <= min_var1[1]]
|
| 241 |
+
working_data = working_data[working_data['Team'].isin(team_var1)]
|
| 242 |
+
working_data = working_data[working_data['Player'].isin(player_var1)]
|
| 243 |
+
season_long_table = seasonlong_build(working_data)
|
| 244 |
season_long_table = season_long_table.set_index('Player')
|
| 245 |
display.dataframe(season_long_table.style.format(precision=2), height=750, use_container_width = True)
|
| 246 |
|
| 247 |
elif split_var1 == 'Gamelogs':
|
| 248 |
+
working_data = working_data[working_data['Date'] >= low_date]
|
| 249 |
+
working_data = working_data[working_data['Date'] <= high_date]
|
| 250 |
+
working_data = working_data[working_data['Min'] >= min_var1[0]]
|
| 251 |
+
working_data = working_data[working_data['Min'] <= min_var1[1]]
|
| 252 |
+
working_data = working_data[working_data['Team'].isin(team_var1)]
|
| 253 |
+
working_data = working_data[working_data['Player'].isin(player_var1)]
|
| 254 |
+
working_data = working_data.reset_index(drop=True)
|
| 255 |
display = st.container()
|
| 256 |
|
| 257 |
bottom_menu = st.columns((4, 1, 1))
|
|
|
|
| 259 |
batch_size = st.selectbox("Page Size", options=[25, 50, 100])
|
| 260 |
with bottom_menu[1]:
|
| 261 |
total_pages = (
|
| 262 |
+
int(len(working_data) / batch_size) if int(len(working_data) / batch_size) > 0 else 1
|
| 263 |
)
|
| 264 |
current_page = st.number_input(
|
| 265 |
"Page", min_value=1, max_value=total_pages, step=1
|
|
|
|
| 268 |
st.markdown(f"Page **{current_page}** of **{total_pages}** ")
|
| 269 |
|
| 270 |
|
| 271 |
+
pages = split_frame(working_data, batch_size)
|
| 272 |
# pages = pages.set_index('Player')
|
| 273 |
display.dataframe(data=pages[current_page - 1].style.format(precision=2), height=500, use_container_width=True)
|
| 274 |
|
|
|
|
| 309 |
min_var1_t2 = st.slider("Is there a certain minutes range you want to view?", 0, 60, (0, 60), key='min_var1_t2')
|
| 310 |
|
| 311 |
with col2:
|
| 312 |
+
working_data = gamelog_table
|
| 313 |
if split_var1_t2 == 'Specific Teams':
|
| 314 |
display = st.container()
|
| 315 |
+
working_data = working_data.sort_values(by='Fantasy', ascending=False)
|
| 316 |
+
working_data = working_data[working_data['Date'] >= low_date_t2]
|
| 317 |
+
working_data = working_data[working_data['Date'] <= high_date_t2]
|
| 318 |
+
working_data = working_data[working_data['Min'] >= min_var1_t2[0]]
|
| 319 |
+
working_data = working_data[working_data['Min'] <= min_var1_t2[1]]
|
| 320 |
+
working_data = working_data[working_data['Team'].isin(corr_var1_t2)]
|
| 321 |
if corr_var == 'Fantasy':
|
| 322 |
+
corr_display = run_fantasy_corr(working_data)
|
| 323 |
elif corr_var == 'Minutes':
|
| 324 |
+
corr_display = run_min_corr(working_data)
|
| 325 |
display.dataframe(corr_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=1000, use_container_width = True)
|
| 326 |
|
| 327 |
elif split_var1_t2 == 'Specific Players':
|
| 328 |
display = st.container()
|
| 329 |
+
working_data = working_data.sort_values(by='Fantasy', ascending=False)
|
| 330 |
+
working_data = working_data[working_data['Date'] >= low_date_t2]
|
| 331 |
+
working_data = working_data[working_data['Date'] <= high_date_t2]
|
| 332 |
+
working_data = working_data[working_data['Min'] >= min_var1_t2[0]]
|
| 333 |
+
working_data = working_data[working_data['Min'] <= min_var1_t2[1]]
|
| 334 |
+
working_data = working_data[working_data['Player'].isin(corr_var1_t2)]
|
| 335 |
if corr_var == 'Fantasy':
|
| 336 |
+
corr_display = run_fantasy_corr(working_data)
|
| 337 |
elif corr_var == 'Minutes':
|
| 338 |
+
corr_display = run_min_corr(working_data)
|
| 339 |
display.dataframe(corr_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 340 |
|
| 341 |
with tab3:
|
|
|
|
| 368 |
min_var3 = st.slider("Is there a certain minutes range you want to view?", 0, 60, (0, 60), key='min_var3')
|
| 369 |
|
| 370 |
with col2:
|
| 371 |
+
working_data = gamelog_table
|
| 372 |
+
working_data = working_data[gamelog_table['Date'] >= low_date3]
|
| 373 |
+
working_data = working_data[gamelog_table['Date'] <= high_date3]
|
| 374 |
+
season_long_table = seasonlong_build(working_data)
|
| 375 |
+
fantasy_dict = dict(zip(season_long_table['Player'], season_long_table['Fantasy']))
|
| 376 |
+
fd_fantasy_dict = dict(zip(season_long_table['Player'], season_long_table['FD_Fantasy']))
|
| 377 |
|
| 378 |
+
working_data = working_data[working_data['Pos'] == pos_var3]
|
| 379 |
+
working_data = working_data[working_data['Min'] >= min_var3[0]]
|
| 380 |
+
working_data = working_data[working_data['Min'] <= min_var3[1]]
|
| 381 |
+
working_data = working_data[working_data['Opp'].isin(team_var3)]
|
| 382 |
+
working_data = working_data.reset_index(drop=True)
|
| 383 |
+
gamelog_display = working_data[['Player', 'Pos', 'Team', 'Opp', 'Date', 'Min', 'Fantasy', 'FD_Fantasy']]
|
| 384 |
+
gamelog_display['Avg_Fantasy'] = gamelog_display['Player'].map(fantasy_dict)
|
| 385 |
+
gamelog_display['Avg_FD_Fantasy'] = gamelog_display['Player'].map(fd_fantasy_dict)
|
| 386 |
display = st.container()
|
| 387 |
|
| 388 |
# pages = pages.set_index('Player')
|