James McCool
commited on
Commit
·
20a3bf0
1
Parent(s):
14ac337
Add info_columns_dict initialization in app.py: implement logic to store key metrics from working_frame in session state for improved data tracking, and refactor filtering logic to enhance clarity and maintainability of lineup processing.
Browse files
app.py
CHANGED
|
@@ -876,6 +876,16 @@ with tab2:
|
|
| 876 |
axis=1
|
| 877 |
)
|
| 878 |
st.session_state['working_frame'] = predict_dupes(st.session_state['working_frame'], st.session_state['map_dict'], site_var, type_var, Contest_Size, strength_var, sport_var)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 879 |
if 'trimming_dict_maxes' not in st.session_state:
|
| 880 |
st.session_state['trimming_dict_maxes'] = {
|
| 881 |
'Own': st.session_state['working_frame']['Own'].max(),
|
|
@@ -909,28 +919,20 @@ with tab2:
|
|
| 909 |
|
| 910 |
submitted = st.form_submit_button("Submit")
|
| 911 |
if submitted:
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
'median': st.session_state['working_frame']['median'].max(),
|
| 919 |
-
'Finish_percentile': st.session_state['working_frame']['Finish_percentile'].max()
|
| 920 |
-
}
|
| 921 |
-
st.session_state['working_frame'] = st.session_state['working_frame'][st.session_state['working_frame']['Dupes'] <= max_dupes]
|
| 922 |
-
st.session_state['working_frame'] = st.session_state['working_frame'][st.session_state['working_frame']['salary'] >= min_salary]
|
| 923 |
-
st.session_state['working_frame'] = st.session_state['working_frame'][st.session_state['working_frame']['salary'] <= max_salary]
|
| 924 |
-
st.session_state['working_frame'] = st.session_state['working_frame'][st.session_state['working_frame']['Finish_percentile'] <= max_finish_percentile]
|
| 925 |
-
st.session_state['working_frame'] = st.session_state['working_frame'][st.session_state['working_frame']['Lineup Edge'] >= min_lineup_edge]
|
| 926 |
if stack_dict is not None:
|
| 927 |
if stack_toggle == 'All Stacks':
|
| 928 |
-
|
| 929 |
-
|
| 930 |
else:
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
st.session_state['working_frame'] =
|
| 934 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 935 |
|
| 936 |
with st.expander('Micro Filter Options'):
|
|
@@ -944,32 +946,24 @@ with tab2:
|
|
| 944 |
|
| 945 |
submitted = st.form_submit_button("Submit")
|
| 946 |
if submitted:
|
| 947 |
-
|
| 948 |
-
if 'trimming_dict_maxes' not in st.session_state:
|
| 949 |
-
st.session_state['trimming_dict_maxes'] = {
|
| 950 |
-
'Own': st.session_state['working_frame']['Own'].max(),
|
| 951 |
-
'Geomean': st.session_state['working_frame']['Geomean'].max(),
|
| 952 |
-
'Weighted Own': st.session_state['working_frame']['Weighted Own'].max(),
|
| 953 |
-
'median': st.session_state['working_frame']['median'].max(),
|
| 954 |
-
'Finish_percentile': st.session_state['working_frame']['Finish_percentile'].max()
|
| 955 |
-
}
|
| 956 |
if player_remove:
|
| 957 |
# Create mask for lineups that contain any of the removed players
|
| 958 |
-
player_columns = [col for col in
|
| 959 |
-
remove_mask =
|
| 960 |
lambda row: not any(player in list(row) for player in player_remove), axis=1
|
| 961 |
)
|
| 962 |
-
|
| 963 |
|
| 964 |
if player_lock:
|
| 965 |
# Create mask for lineups that contain all locked players
|
| 966 |
-
player_columns = [col for col in
|
| 967 |
|
| 968 |
-
lock_mask =
|
| 969 |
lambda row: all(player in list(row) for player in player_lock), axis=1
|
| 970 |
)
|
| 971 |
-
|
| 972 |
-
st.session_state['working_frame'] =
|
| 973 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 974 |
|
| 975 |
with st.expander('Trimming Options'):
|
|
|
|
| 876 |
axis=1
|
| 877 |
)
|
| 878 |
st.session_state['working_frame'] = predict_dupes(st.session_state['working_frame'], st.session_state['map_dict'], site_var, type_var, Contest_Size, strength_var, sport_var)
|
| 879 |
+
if 'info_columns_dict' not in st.session_state:
|
| 880 |
+
st.session_state['info_columns_dict'] = {
|
| 881 |
+
'Dupes': st.session_state['working_frame']['Dupes'],
|
| 882 |
+
'Finish_percentile': st.session_state['working_frame']['Finish_percentile'],
|
| 883 |
+
'Win%': st.session_state['working_frame']['Win%'],
|
| 884 |
+
'Lineup Edge': st.session_state['working_frame']['Lineup Edge'],
|
| 885 |
+
'Weighted Own': st.session_state['working_frame']['Weighted Own'],
|
| 886 |
+
'Geomean': st.session_state['working_frame']['Geomean'],
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
if 'trimming_dict_maxes' not in st.session_state:
|
| 890 |
st.session_state['trimming_dict_maxes'] = {
|
| 891 |
'Own': st.session_state['working_frame']['Own'].max(),
|
|
|
|
| 919 |
|
| 920 |
submitted = st.form_submit_button("Submit")
|
| 921 |
if submitted:
|
| 922 |
+
parsed_frame = st.session_state['working_frame'].copy()
|
| 923 |
+
parsed_frame = parsed_frame[parsed_frame['Dupes'] <= max_dupes]
|
| 924 |
+
parsed_frame = parsed_frame[parsed_frame['salary'] >= min_salary]
|
| 925 |
+
parsed_frame = parsed_frame[parsed_frame['salary'] <= max_salary]
|
| 926 |
+
parsed_frame = parsed_frame[parsed_frame['Finish_percentile'] <= max_finish_percentile]
|
| 927 |
+
parsed_frame = parsed_frame[parsed_frame['Lineup Edge'] >= min_lineup_edge]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 928 |
if stack_dict is not None:
|
| 929 |
if stack_toggle == 'All Stacks':
|
| 930 |
+
parsed_frame = parsed_frame
|
| 931 |
+
parsed_frame = parsed_frame[~parsed_frame['Stack'].isin(stack_remove)]
|
| 932 |
else:
|
| 933 |
+
parsed_frame = parsed_frame[parsed_frame['Stack'].isin(stack_selections)]
|
| 934 |
+
parsed_frame = parsed_frame[~parsed_frame['Stack'].isin(stack_remove)]
|
| 935 |
+
st.session_state['working_frame'] = parsed_frame.sort_values(by='median', ascending=False)
|
| 936 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 937 |
|
| 938 |
with st.expander('Micro Filter Options'):
|
|
|
|
| 946 |
|
| 947 |
submitted = st.form_submit_button("Submit")
|
| 948 |
if submitted:
|
| 949 |
+
parsed_frame = st.session_state['working_frame'].copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 950 |
if player_remove:
|
| 951 |
# Create mask for lineups that contain any of the removed players
|
| 952 |
+
player_columns = [col for col in parsed_frame.columns if col not in excluded_cols]
|
| 953 |
+
remove_mask = parsed_frame[player_columns].apply(
|
| 954 |
lambda row: not any(player in list(row) for player in player_remove), axis=1
|
| 955 |
)
|
| 956 |
+
parsed_frame = parsed_frame[remove_mask]
|
| 957 |
|
| 958 |
if player_lock:
|
| 959 |
# Create mask for lineups that contain all locked players
|
| 960 |
+
player_columns = [col for col in parsed_frame.columns if col not in excluded_cols]
|
| 961 |
|
| 962 |
+
lock_mask = parsed_frame[player_columns].apply(
|
| 963 |
lambda row: all(player in list(row) for player in player_lock), axis=1
|
| 964 |
)
|
| 965 |
+
parsed_frame = parsed_frame[lock_mask]
|
| 966 |
+
st.session_state['working_frame'] = parsed_frame.sort_values(by='median', ascending=False)
|
| 967 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 968 |
|
| 969 |
with st.expander('Trimming Options'):
|