James McCool
commited on
Commit
·
da9634d
1
Parent(s):
223a580
Enhance app.py to support NBA and NFL player projections with distinct formatting. Introduced nba_player_roo_format and nfl_player_roo_format for improved data display based on sport selection. Updated dataframe rendering logic to conditionally format projections based on the selected sport, ensuring a more tailored user experience.
Browse files
app.py
CHANGED
@@ -28,9 +28,12 @@ game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%
|
|
28 |
team_roo_format = {'Top Score%': '{:.2%}','0 Runs': '{:.2%}', '1 Run': '{:.2%}', '2 Runs': '{:.2%}', '3 Runs': '{:.2%}', '4 Runs': '{:.2%}',
|
29 |
'5 Runs': '{:.2%}','6 Runs': '{:.2%}', '7 Runs': '{:.2%}', '8 Runs': '{:.2%}', '9 Runs': '{:.2%}', '10 Runs': '{:.2%}'}
|
30 |
|
31 |
-
|
32 |
'4x%': '{:.2%}','GPP%': '{:.2%}'}
|
33 |
|
|
|
|
|
|
|
34 |
expose_format = {'Proj Own': '{:.2%}','Exposure': '{:.2%}'}
|
35 |
|
36 |
all_dk_player_projections = st.secrets["NFL_data"]
|
@@ -137,7 +140,10 @@ with tab1:
|
|
137 |
with hold_container:
|
138 |
hold_container = st.empty()
|
139 |
display_Proj = display_Proj
|
140 |
-
|
|
|
|
|
|
|
141 |
|
142 |
st.download_button(
|
143 |
label="Export Tables",
|
@@ -245,7 +251,7 @@ with tab2:
|
|
245 |
cpt_proj['Team'] = display_baselines['Team']
|
246 |
cpt_proj['Opp'] = display_baselines['Opp']
|
247 |
cpt_proj['Median'] = display_baselines['Median'] * 1.5
|
248 |
-
cpt_proj['Own'] = display_baselines['
|
249 |
cpt_proj['lock'] = display_baselines['cpt_lock']
|
250 |
cpt_proj['roster'] = 'CPT'
|
251 |
if len(lock_var1) > 0:
|
|
|
28 |
team_roo_format = {'Top Score%': '{:.2%}','0 Runs': '{:.2%}', '1 Run': '{:.2%}', '2 Runs': '{:.2%}', '3 Runs': '{:.2%}', '4 Runs': '{:.2%}',
|
29 |
'5 Runs': '{:.2%}','6 Runs': '{:.2%}', '7 Runs': '{:.2%}', '8 Runs': '{:.2%}', '9 Runs': '{:.2%}', '10 Runs': '{:.2%}'}
|
30 |
|
31 |
+
nfl_player_roo_format = {'Top_finish': '{:.2%}','Top_5_finish': '{:.2%}', 'Top_10_finish': '{:.2%}', '20+%': '{:.2%}', '2x%': '{:.2%}', '3x%': '{:.2%}',
|
32 |
'4x%': '{:.2%}','GPP%': '{:.2%}'}
|
33 |
|
34 |
+
nba_player_roo_format = {'Top_finish': '{:.2%}','Top_5_finish': '{:.2%}', 'Top_10_finish': '{:.2%}', '20+%': '{:.2%}', '4x%': '{:.2%}', '5x%': '{:.2%}',
|
35 |
+
'6x%': '{:.2%}','GPP%': '{:.2%}'}
|
36 |
+
|
37 |
expose_format = {'Proj Own': '{:.2%}','Exposure': '{:.2%}'}
|
38 |
|
39 |
all_dk_player_projections = st.secrets["NFL_data"]
|
|
|
140 |
with hold_container:
|
141 |
hold_container = st.empty()
|
142 |
display_Proj = display_Proj
|
143 |
+
if sport_var2 == 'NBA':
|
144 |
+
st.dataframe(display_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(nba_player_roo_format, precision=2), height=1000, use_container_width = True)
|
145 |
+
elif sport_var2 == 'NFL':
|
146 |
+
st.dataframe(display_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(nfl_player_roo_format, precision=2), height=1000, use_container_width = True)
|
147 |
|
148 |
st.download_button(
|
149 |
label="Export Tables",
|
|
|
251 |
cpt_proj['Team'] = display_baselines['Team']
|
252 |
cpt_proj['Opp'] = display_baselines['Opp']
|
253 |
cpt_proj['Median'] = display_baselines['Median'] * 1.5
|
254 |
+
cpt_proj['Own'] = display_baselines['CPT_Own']
|
255 |
cpt_proj['lock'] = display_baselines['cpt_lock']
|
256 |
cpt_proj['roster'] = 'CPT'
|
257 |
if len(lock_var1) > 0:
|