XPMaster commited on
Commit
1a41cf9
·
1 Parent(s): 0d1524a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -15
app.py CHANGED
@@ -137,15 +137,21 @@ with col3:
137
 
138
 
139
 
140
- # Set initial session states
141
- if 'active_page' not in st.session_state:
142
- st.session_state.active_page = None
143
- if 'premiums_selection' not in st.session_state:
144
- st.session_state.premiums_selection = False
145
- if 'claims_recoveries_selection' not in st.session_state:
146
- st.session_state.claims_recoveries_selection = False
147
- if 'claims_count_selection' not in st.session_state:
148
- st.session_state.claims_count_selection = False
 
 
 
 
 
 
149
 
150
  # Helper function to check if a string has more than 50% numeric characters
151
  def is_mostly_numeric(s):
@@ -213,6 +219,7 @@ def column_selection_ui(dataframe_key, selection_key):
213
  }
214
 
215
 
 
216
  upload_col1, upload_col2, upload_col3 = st.columns(3)
217
  with upload_col1:
218
  uploaded_file_premiums = st.file_uploader("Upload Premiums Data", key="premiums")
@@ -222,7 +229,7 @@ with upload_col3:
222
  uploaded_file_claims_count = st.file_uploader("Upload Claims Count Data", key="claims_count")
223
 
224
  # Only show buttons if we're on the home page
225
- if st.session_state.current_page == 'home':
226
  button_col1, button_col2, button_col3 = st.columns(3)
227
  with button_col1:
228
  if uploaded_file_premiums and st.button("Select Premiums columns"):
@@ -239,14 +246,14 @@ if st.session_state.current_page == 'home':
239
  process_file(uploaded_file_claims_count, 'claims_count_df')
240
 
241
  # Display the column selection UI based on the current page
242
- if st.session_state.current_page == 'premiums_df':
243
  column_selection_ui('premiums_df')
244
- elif st.session_state.current_page == 'claims_recoveries_df':
245
  column_selection_ui('claims_recoveries_df')
246
- elif st.session_state.current_page == 'claims_count_df':
247
  column_selection_ui('claims_count_df')
248
 
249
  # Add a button to go back to the home page from any selection page
250
- if st.session_state.current_page != 'home':
251
  if st.button("Back to Home"):
252
- st.session_state.current_page = 'home'
 
137
 
138
 
139
 
140
+ # Ensure the session state variables are initialized
141
+ if 'current_page' not in st.session_state:
142
+ st.session_state.current_page = 'home'
143
+ if 'premiums_df' not in st.session_state:
144
+ st.session_state.premiums_df = None
145
+ if 'claims_recoveries_df' not in st.session_state:
146
+ st.session_state.claims_recoveries_df = None
147
+ if 'claims_count_df' not in st.session_state:
148
+ st.session_state.claims_count_df = None
149
+
150
+ if 'current_page' not in st.session_state:
151
+ st.session_state['current_page'] = 'home'
152
+ if 'premiums_df' not in st.session_state:
153
+ st.session_state['premiums_df'] = None
154
+ # ... Similarly for other dataframes
155
 
156
  # Helper function to check if a string has more than 50% numeric characters
157
  def is_mostly_numeric(s):
 
219
  }
220
 
221
 
222
+ # File uploader and buttons
223
  upload_col1, upload_col2, upload_col3 = st.columns(3)
224
  with upload_col1:
225
  uploaded_file_premiums = st.file_uploader("Upload Premiums Data", key="premiums")
 
229
  uploaded_file_claims_count = st.file_uploader("Upload Claims Count Data", key="claims_count")
230
 
231
  # Only show buttons if we're on the home page
232
+ if st.session_state['current_page'] == 'home':
233
  button_col1, button_col2, button_col3 = st.columns(3)
234
  with button_col1:
235
  if uploaded_file_premiums and st.button("Select Premiums columns"):
 
246
  process_file(uploaded_file_claims_count, 'claims_count_df')
247
 
248
  # Display the column selection UI based on the current page
249
+ if st.session_state['current_page'] == 'premiums_df':
250
  column_selection_ui('premiums_df')
251
+ elif st.session_state['current_page'] == 'claims_recoveries_df':
252
  column_selection_ui('claims_recoveries_df')
253
+ elif st.session_state['current_page'] == 'claims_count_df':
254
  column_selection_ui('claims_count_df')
255
 
256
  # Add a button to go back to the home page from any selection page
257
+ if st.session_state['current_page'] != 'home':
258
  if st.button("Back to Home"):
259
+ st.session_state['current_page'] = 'home'