XPMaster commited on
Commit
3a485f7
·
1 Parent(s): 33c2e73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -16
app.py CHANGED
@@ -161,18 +161,10 @@ def column_selection_ui(dataframe_key, selection_key):
161
  if not any(not isinstance(x, str) or is_mostly_numeric(x) for x in st.session_state[dataframe_key][col].dropna())
162
  ]
163
 
164
- # Restore previous selections if they exist
165
- previous_selections = st.session_state.get(f'{selection_key}_selections', {})
166
-
167
  col1, col2 = st.columns(2)
168
  with col1:
169
- lob_column = st.selectbox(
170
- 'Choose the column for "lob":',
171
- string_columns,
172
- key=f'lob_column_{selection_key}',
173
- index=string_columns.index(previous_selections.get('lob_column')) if previous_selections.get('lob_column') in string_columns else 0
174
- )
175
- selected_lob_values = previous_selections.get('selected_lob_values', [])
176
 
177
  with col2:
178
  st.write("Select values for filtering:")
@@ -180,12 +172,12 @@ def column_selection_ui(dataframe_key, selection_key):
180
  unique_values = st.session_state[dataframe_key][lob_column].unique()
181
  unique_values.sort()
182
  for value in unique_values:
183
- is_checked = value in selected_lob_values
184
- if st.checkbox(f"{value}", key=f"checkbox_{value}_{selection_key}", value=is_checked):
185
- if not is_checked:
186
- selected_lob_values.append(value)
187
- else:
188
- selected_lob_values.remove(value)
189
 
190
  # Filter the DataFrame based on selected 'lob' values
191
  if selected_lob_values:
 
161
  if not any(not isinstance(x, str) or is_mostly_numeric(x) for x in st.session_state[dataframe_key][col].dropna())
162
  ]
163
 
 
 
 
164
  col1, col2 = st.columns(2)
165
  with col1:
166
+ lob_column = st.selectbox('Choose the column for "lob":', string_columns, key=f'lob_column_{selection_key}')
167
+ selected_lob_values = []
 
 
 
 
 
168
 
169
  with col2:
170
  st.write("Select values for filtering:")
 
172
  unique_values = st.session_state[dataframe_key][lob_column].unique()
173
  unique_values.sort()
174
  for value in unique_values:
175
+ if st.checkbox(f"{value}", key=f"checkbox_{value}_{selection_key}"):
176
+ selected_lob_values.append(value)
177
+
178
+ # Initialize the variables to prevent UnboundLocalError
179
+ valuation_as_at = None
180
+ quarter_bracket = None
181
 
182
  # Filter the DataFrame based on selected 'lob' values
183
  if selected_lob_values: