Spaces:
Running
Running
James McCool
commited on
Commit
·
acf3604
1
Parent(s):
f956786
Refactor 'Stack Finder' tab to prioritize QBs in player combinations and ensure valid combinations have QBs in the first position
Browse files- src/streamlit_app.py +12 -9
src/streamlit_app.py
CHANGED
|
@@ -253,17 +253,22 @@ if selected_tab == 'Stack Finder':
|
|
| 253 |
working_baselines = working_baselines[working_baselines['Position'] != 'DST']
|
| 254 |
working_baselines = working_baselines[working_baselines['Position'] != 'K']
|
| 255 |
qb_var = qb_dict[cur_team]
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
comb = combinations(order_list, stack_size)
|
| 259 |
|
| 260 |
for i in list(comb):
|
| 261 |
-
if qb_var in i:
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
|
|
|
| 267 |
|
| 268 |
comb_DF = pd.DataFrame(comb_list)
|
| 269 |
|
|
@@ -418,8 +423,6 @@ if selected_tab == 'Stack Finder':
|
|
| 418 |
except:
|
| 419 |
cut_var += 1
|
| 420 |
|
| 421 |
-
pos_df = comb_DF.map(pos_dict)
|
| 422 |
-
print(pos_df.head(10))
|
| 423 |
st.session_state['display_frame'] = comb_DF
|
| 424 |
if 'display_frame' in st.session_state:
|
| 425 |
st.dataframe(st.session_state['display_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), hide_index=True, use_container_width = True)
|
|
|
|
| 253 |
working_baselines = working_baselines[working_baselines['Position'] != 'DST']
|
| 254 |
working_baselines = working_baselines[working_baselines['Position'] != 'K']
|
| 255 |
qb_var = qb_dict[cur_team]
|
| 256 |
+
|
| 257 |
+
# Create order_list with QBs first to ensure they appear in first column
|
| 258 |
+
qb_players = working_baselines[working_baselines['Position'] == 'QB']['Player'].unique()
|
| 259 |
+
other_players = working_baselines[working_baselines['Position'] != 'QB']['Player'].unique()
|
| 260 |
+
order_list = list(qb_players) + list(other_players)
|
| 261 |
|
| 262 |
comb = combinations(order_list, stack_size)
|
| 263 |
|
| 264 |
for i in list(comb):
|
| 265 |
+
if qb_var in i and is_valid_combination(i):
|
| 266 |
+
# Ensure QB is in first position
|
| 267 |
+
combo_list = list(i)
|
| 268 |
+
if qb_var in combo_list:
|
| 269 |
+
qb_index = combo_list.index(qb_var)
|
| 270 |
+
combo_list[0], combo_list[qb_index] = combo_list[qb_index], combo_list[0]
|
| 271 |
+
comb_list.append(tuple(combo_list))
|
| 272 |
|
| 273 |
comb_DF = pd.DataFrame(comb_list)
|
| 274 |
|
|
|
|
| 423 |
except:
|
| 424 |
cut_var += 1
|
| 425 |
|
|
|
|
|
|
|
| 426 |
st.session_state['display_frame'] = comb_DF
|
| 427 |
if 'display_frame' in st.session_state:
|
| 428 |
st.dataframe(st.session_state['display_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), hide_index=True, use_container_width = True)
|