Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -124,31 +124,38 @@ with tab3:
|
|
124 |
|
125 |
if prop_type_var_sp == 'Strikeouts':
|
126 |
df['Median'] = df['Strikeouts']
|
|
|
127 |
elif prop_type_var_sp == 'Wins':
|
128 |
df['Median'] = df['Wins']
|
|
|
129 |
elif prop_type_var_sp == 'Quality_starts':
|
130 |
df['Median'] = df['Quality_starts']
|
|
|
131 |
|
132 |
-
flex_file = df
|
133 |
flex_file.rename(columns={"Name": "Player"}, inplace = True)
|
134 |
-
flex_file['Floor'] = (flex_file['Median'] * .
|
135 |
-
flex_file['Ceiling'] = flex_file['Median'] * flex_file['Ceiling_var']
|
136 |
flex_file['STD'] = (flex_file['Median']/3)
|
137 |
flex_file = flex_file[['Player', 'Floor', 'Median', 'Ceiling', 'STD']]
|
138 |
|
139 |
-
hold_file = flex_file
|
140 |
-
|
141 |
-
|
|
|
|
|
142 |
overall_players = overall_file[['Player']]
|
143 |
|
144 |
-
for x in range(0,total_sims):
|
145 |
-
overall_file[
|
|
|
146 |
|
147 |
-
|
|
|
148 |
overall_file.astype('int').dtypes
|
149 |
|
150 |
players_only = hold_file[['Player']]
|
151 |
-
raw_lineups_file = players_only
|
152 |
|
153 |
for x in range(0,total_sims):
|
154 |
maps_dict = {'proj_map':dict(zip(hold_file.Player,overall_file[x]))}
|
@@ -171,6 +178,7 @@ with tab3:
|
|
171 |
|
172 |
final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
|
173 |
final_Proj = final_Proj[['Player', '10%', 'Median', '90%', 'Top_finish', 'Top_5_finish', 'Top_10_finish']]
|
|
|
174 |
with df_hold_container.container():
|
175 |
df_hold_container = st.empty()
|
176 |
st.dataframe(final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
@@ -200,35 +208,44 @@ with tab4:
|
|
200 |
|
201 |
if prop_type_var_h == 'Hits':
|
202 |
df['Median'] = df['xHits']
|
|
|
203 |
elif prop_type_var_h == 'Doubles':
|
204 |
df['Median'] = df['Doubles']
|
|
|
205 |
elif prop_type_var_h == 'Home Runs':
|
206 |
df['Median'] = df['Homeruns']
|
|
|
207 |
elif prop_type_var_h == 'RBI':
|
208 |
df['Median'] = df['RBI']
|
|
|
209 |
elif prop_type_var_h == 'Stolen Bases':
|
210 |
df['Median'] = df['Stolen_bases']
|
|
|
211 |
|
212 |
-
flex_file = df
|
213 |
flex_file.rename(columns={"Name": "Player"}, inplace = True)
|
214 |
-
flex_file['Floor'] = (flex_file['Median'] * .
|
215 |
-
flex_file['Ceiling'] = flex_file['Median'] * flex_file['Ceiling_var']
|
216 |
flex_file['STD'] = (flex_file['Median']/2)
|
217 |
flex_file = flex_file[['Player', 'Floor', 'Median', 'Ceiling', 'STD']]
|
218 |
|
219 |
-
hold_file = flex_file
|
220 |
-
|
221 |
-
|
|
|
|
|
222 |
overall_players = overall_file[['Player']]
|
223 |
|
224 |
-
for x in range(0,total_sims):
|
225 |
-
overall_file[
|
|
|
226 |
|
227 |
-
|
|
|
228 |
overall_file.astype('int').dtypes
|
229 |
|
230 |
players_only = hold_file[['Player']]
|
231 |
-
raw_lineups_file = players_only
|
232 |
|
233 |
for x in range(0,total_sims):
|
234 |
maps_dict = {'proj_map':dict(zip(hold_file.Player,overall_file[x]))}
|
@@ -252,6 +269,6 @@ with tab4:
|
|
252 |
final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
|
253 |
final_Proj = final_Proj[['Player', '10%', 'Median', '90%', 'Top_finish', 'Top_5_finish', 'Top_10_finish']]
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
|
|
124 |
|
125 |
if prop_type_var_sp == 'Strikeouts':
|
126 |
df['Median'] = df['Strikeouts']
|
127 |
+
stat_cap = 250
|
128 |
elif prop_type_var_sp == 'Wins':
|
129 |
df['Median'] = df['Wins']
|
130 |
+
stat_cap = 15
|
131 |
elif prop_type_var_sp == 'Quality_starts':
|
132 |
df['Median'] = df['Quality_starts']
|
133 |
+
stat_cap = 20
|
134 |
|
135 |
+
flex_file = df.copy()
|
136 |
flex_file.rename(columns={"Name": "Player"}, inplace = True)
|
137 |
+
flex_file['Floor'] = (flex_file['Median'] * .15)
|
138 |
+
flex_file['Ceiling'] = np.where((flex_file['Median'] * flex_file['Ceiling_var']) * 1.25 > stat_cap, stat_cap, (flex_file['Median'] * flex_file['Ceiling_var']) * 1.25)
|
139 |
flex_file['STD'] = (flex_file['Median']/3)
|
140 |
flex_file = flex_file[['Player', 'Floor', 'Median', 'Ceiling', 'STD']]
|
141 |
|
142 |
+
hold_file = flex_file.copy()
|
143 |
+
hold_file = hold_file.sort_values(by='Median', ascending=False)
|
144 |
+
overall_file = flex_file.copy()
|
145 |
+
overall_file = overall_file.sort_values(by='Median', ascending=False)
|
146 |
+
|
147 |
overall_players = overall_file[['Player']]
|
148 |
|
149 |
+
for x in range(0,total_sims):
|
150 |
+
overall_file['g'] = np.random.normal(overall_file['Median'],overall_file['STD'])
|
151 |
+
overall_file[x] = np.where((overall_file['g']<=overall_file['Ceiling']),overall_file['g'],overall_file['Ceiling'])
|
152 |
|
153 |
+
check_file = overall_file.copy()
|
154 |
+
overall_file=overall_file.drop(['Player', 'Floor', 'Median', 'Ceiling', 'STD', 'g'], axis=1)
|
155 |
overall_file.astype('int').dtypes
|
156 |
|
157 |
players_only = hold_file[['Player']]
|
158 |
+
raw_lineups_file = players_only.copy()
|
159 |
|
160 |
for x in range(0,total_sims):
|
161 |
maps_dict = {'proj_map':dict(zip(hold_file.Player,overall_file[x]))}
|
|
|
178 |
|
179 |
final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
|
180 |
final_Proj = final_Proj[['Player', '10%', 'Median', '90%', 'Top_finish', 'Top_5_finish', 'Top_10_finish']]
|
181 |
+
|
182 |
with df_hold_container.container():
|
183 |
df_hold_container = st.empty()
|
184 |
st.dataframe(final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
|
|
208 |
|
209 |
if prop_type_var_h == 'Hits':
|
210 |
df['Median'] = df['xHits']
|
211 |
+
stat_cap = 250
|
212 |
elif prop_type_var_h == 'Doubles':
|
213 |
df['Median'] = df['Doubles']
|
214 |
+
stat_cap = 50
|
215 |
elif prop_type_var_h == 'Home Runs':
|
216 |
df['Median'] = df['Homeruns']
|
217 |
+
stat_cap = 65
|
218 |
elif prop_type_var_h == 'RBI':
|
219 |
df['Median'] = df['RBI']
|
220 |
+
stat_cap = 150
|
221 |
elif prop_type_var_h == 'Stolen Bases':
|
222 |
df['Median'] = df['Stolen_bases']
|
223 |
+
stat_cap = 80
|
224 |
|
225 |
+
flex_file = df.copy()
|
226 |
flex_file.rename(columns={"Name": "Player"}, inplace = True)
|
227 |
+
flex_file['Floor'] = (flex_file['Median'] * .15)
|
228 |
+
flex_file['Ceiling'] = np.where((flex_file['Median'] * flex_file['Ceiling_var']) * 1.25 > stat_cap, stat_cap, (flex_file['Median'] * flex_file['Ceiling_var']) * 1.25)
|
229 |
flex_file['STD'] = (flex_file['Median']/2)
|
230 |
flex_file = flex_file[['Player', 'Floor', 'Median', 'Ceiling', 'STD']]
|
231 |
|
232 |
+
hold_file = flex_file.copy()
|
233 |
+
hold_file = hold_file.sort_values(by='Median', ascending=False)
|
234 |
+
overall_file = flex_file.copy()
|
235 |
+
overall_file = overall_file.sort_values(by='Median', ascending=False)
|
236 |
+
|
237 |
overall_players = overall_file[['Player']]
|
238 |
|
239 |
+
for x in range(0,total_sims):
|
240 |
+
overall_file['g'] = np.random.normal(overall_file['Median'],overall_file['STD'])
|
241 |
+
overall_file[x] = np.where((overall_file['g']<=overall_file['Ceiling']),overall_file['g'],overall_file['Ceiling'])
|
242 |
|
243 |
+
check_file = overall_file.copy()
|
244 |
+
overall_file=overall_file.drop(['Player', 'Floor', 'Median', 'Ceiling', 'STD', 'g'], axis=1)
|
245 |
overall_file.astype('int').dtypes
|
246 |
|
247 |
players_only = hold_file[['Player']]
|
248 |
+
raw_lineups_file = players_only.copy()
|
249 |
|
250 |
for x in range(0,total_sims):
|
251 |
maps_dict = {'proj_map':dict(zip(hold_file.Player,overall_file[x]))}
|
|
|
269 |
final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
|
270 |
final_Proj = final_Proj[['Player', '10%', 'Median', '90%', 'Top_finish', 'Top_5_finish', 'Top_10_finish']]
|
271 |
|
272 |
+
with df_hold_container.container():
|
273 |
+
df_hold_container = st.empty()
|
274 |
+
st.dataframe(final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|