Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
9e7c263
1
Parent(s):
95a7eab
added position filtering to top owned run, also added variable size to top owned run
Browse files
app.py
CHANGED
|
@@ -123,11 +123,11 @@ with tab1:
|
|
| 123 |
elif data_var1 != 'User':
|
| 124 |
raw_baselines = fd_roo_raw[fd_roo_raw['slate'] == 'Main Slate']
|
| 125 |
raw_baselines = raw_baselines[raw_baselines['version'] == 'overall']
|
| 126 |
-
check_seq = st.radio("Do you want to check a single player or the top 10 in ownership?", ('Single Player', 'Top
|
| 127 |
if check_seq == 'Single Player':
|
| 128 |
player_check = st.selectbox('Select player to create comps', options = raw_baselines['Player'].unique(), key='dk_player')
|
| 129 |
-
elif check_seq == 'Top
|
| 130 |
-
|
| 131 |
Salary_var = st.number_input('Acceptable +/- Salary range', min_value = 0, max_value = 1000, value = 300, step = 100)
|
| 132 |
Median_var = st.number_input('Acceptable +/- Median range', min_value = 0, max_value = 10, value = 3, step = 1)
|
| 133 |
pos_var1 = st.radio("Compare to all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_var1')
|
|
@@ -155,7 +155,6 @@ with tab1:
|
|
| 155 |
working_roo = raw_baselines
|
| 156 |
working_roo.replace('', 0, inplace=True)
|
| 157 |
|
| 158 |
-
|
| 159 |
own_dict = dict(zip(working_roo.Player, working_roo.Own))
|
| 160 |
team_dict = dict(zip(working_roo.Player, working_roo.Team))
|
| 161 |
opp_dict = dict(zip(working_roo.Player, working_roo.Opp))
|
|
@@ -165,7 +164,6 @@ with tab1:
|
|
| 165 |
if check_seq == 'Single Player':
|
| 166 |
player_var = working_roo.loc[working_roo['Player'] == player_check]
|
| 167 |
player_var = player_var.reset_index()
|
| 168 |
-
|
| 169 |
working_roo = working_roo[working_roo['Position'].isin(pos_var_list)]
|
| 170 |
working_roo = working_roo[working_roo['Team'].isin(team_var1)]
|
| 171 |
working_roo = working_roo.loc[(working_roo['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo['Salary'] <= player_var['Salary'][0] + Salary_var)]
|
|
@@ -244,19 +242,21 @@ with tab1:
|
|
| 244 |
final_Proj = final_Proj.set_index('Player')
|
| 245 |
st.session_state.final_Proj = final_Proj.sort_values(by='Top_finish', ascending=False)
|
| 246 |
|
| 247 |
-
elif check_seq == 'Top
|
|
|
|
|
|
|
|
|
|
| 248 |
final_proj_list = []
|
| 249 |
for players in player_check:
|
| 250 |
players_pos = pos_dict[players]
|
| 251 |
player_var = working_roo.loc[working_roo['Player'] == players]
|
| 252 |
player_var = player_var.reset_index()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
-
|
| 255 |
-
working_roo_temp = working_roo_temp[working_roo_temp['Team'].isin(team_var1)]
|
| 256 |
-
working_roo_temp = working_roo_temp.loc[(working_roo_temp['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo_temp['Salary'] <= player_var['Salary'][0] + Salary_var)]
|
| 257 |
-
working_roo_temp = working_roo_temp.loc[(working_roo_temp['Median'] >= player_var['Median'][0] - Median_var) & (working_roo_temp['Median'] <= player_var['Median'][0] + Median_var)]
|
| 258 |
-
|
| 259 |
-
flex_file = working_roo_temp[['Player', 'Position', 'Salary', 'Median']]
|
| 260 |
flex_file['Floor_raw'] = flex_file['Median'] * .25
|
| 261 |
flex_file['Ceiling_raw'] = flex_file['Median'] * 1.75
|
| 262 |
flex_file['Floor'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * .33), flex_file['Floor_raw'])
|
|
|
|
| 123 |
elif data_var1 != 'User':
|
| 124 |
raw_baselines = fd_roo_raw[fd_roo_raw['slate'] == 'Main Slate']
|
| 125 |
raw_baselines = raw_baselines[raw_baselines['version'] == 'overall']
|
| 126 |
+
check_seq = st.radio("Do you want to check a single player or the top 10 in ownership?", ('Single Player', 'Top X Owned'), key='check_seq')
|
| 127 |
if check_seq == 'Single Player':
|
| 128 |
player_check = st.selectbox('Select player to create comps', options = raw_baselines['Player'].unique(), key='dk_player')
|
| 129 |
+
elif check_seq == 'Top X Owned':
|
| 130 |
+
top_x_var = st.number_input('How many players would you like to check?', min_value = 1, max_value = 10, value = 5, step = 1)
|
| 131 |
Salary_var = st.number_input('Acceptable +/- Salary range', min_value = 0, max_value = 1000, value = 300, step = 100)
|
| 132 |
Median_var = st.number_input('Acceptable +/- Median range', min_value = 0, max_value = 10, value = 3, step = 1)
|
| 133 |
pos_var1 = st.radio("Compare to all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_var1')
|
|
|
|
| 155 |
working_roo = raw_baselines
|
| 156 |
working_roo.replace('', 0, inplace=True)
|
| 157 |
|
|
|
|
| 158 |
own_dict = dict(zip(working_roo.Player, working_roo.Own))
|
| 159 |
team_dict = dict(zip(working_roo.Player, working_roo.Team))
|
| 160 |
opp_dict = dict(zip(working_roo.Player, working_roo.Opp))
|
|
|
|
| 164 |
if check_seq == 'Single Player':
|
| 165 |
player_var = working_roo.loc[working_roo['Player'] == player_check]
|
| 166 |
player_var = player_var.reset_index()
|
|
|
|
| 167 |
working_roo = working_roo[working_roo['Position'].isin(pos_var_list)]
|
| 168 |
working_roo = working_roo[working_roo['Team'].isin(team_var1)]
|
| 169 |
working_roo = working_roo.loc[(working_roo['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo['Salary'] <= player_var['Salary'][0] + Salary_var)]
|
|
|
|
| 242 |
final_Proj = final_Proj.set_index('Player')
|
| 243 |
st.session_state.final_Proj = final_Proj.sort_values(by='Top_finish', ascending=False)
|
| 244 |
|
| 245 |
+
elif check_seq == 'Top X Owned':
|
| 246 |
+
if pos_var1 == 'Specific Positions':
|
| 247 |
+
raw_baselines = raw_baselines[raw_baselines['Position'].isin(pos_var_list)]
|
| 248 |
+
player_check = raw_baselines['Player'].head(top_x_var).tolist()
|
| 249 |
final_proj_list = []
|
| 250 |
for players in player_check:
|
| 251 |
players_pos = pos_dict[players]
|
| 252 |
player_var = working_roo.loc[working_roo['Player'] == players]
|
| 253 |
player_var = player_var.reset_index()
|
| 254 |
+
working_roo = working_roo[working_roo['Position'] == players_pos]
|
| 255 |
+
working_roo = working_roo[working_roo['Team'].isin(team_var1)]
|
| 256 |
+
working_roo = working_roo.loc[(working_roo['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo['Salary'] <= player_var['Salary'][0] + Salary_var)]
|
| 257 |
+
working_roo = working_roo.loc[(working_roo['Median'] >= player_var['Median'][0] - Median_var) & (working_roo['Median'] <= player_var['Median'][0] + Median_var)]
|
| 258 |
|
| 259 |
+
flex_file = working_roo[['Player', 'Position', 'Salary', 'Median']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
flex_file['Floor_raw'] = flex_file['Median'] * .25
|
| 261 |
flex_file['Ceiling_raw'] = flex_file['Median'] * 1.75
|
| 262 |
flex_file['Floor'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * .33), flex_file['Floor_raw'])
|