poemsforaphrodite commited on
Commit
6b4ee7d
1 Parent(s): e0a861f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -475,6 +475,10 @@ def show_tabular_data(df, co):
475
  start_idx = (st.session_state.current_page - 1) * rows_per_page
476
  end_idx = start_idx + rows_per_page
477
 
 
 
 
 
478
  # Add a "Calculate Relevancy" button at the top
479
  if st.button("Calculate Relevancy for Selected"):
480
  selected_indices = [i for i, selected in enumerate(st.session_state.selected_rows) if selected]
@@ -491,12 +495,8 @@ def show_tabular_data(df, co):
491
  for col, header in zip(cols, headers):
492
  col.write(f"**{header}**")
493
 
494
- # Initialize selected_rows in session state if not present
495
- if 'selected_rows' not in st.session_state:
496
- st.session_state.selected_rows = [False] * len(df)
497
-
498
  # Display each row
499
- for index, row in df.iloc[start_idx:end_idx].iterrows():
500
  cols = st.columns([0.5, 3, 2, 1, 1, 1, 1, 1, 1])
501
 
502
  # Checkbox for row selection
 
475
  start_idx = (st.session_state.current_page - 1) * rows_per_page
476
  end_idx = start_idx + rows_per_page
477
 
478
+ # Initialize or update selected_rows in session state
479
+ if 'selected_rows' not in st.session_state or len(st.session_state.selected_rows) != len(df):
480
+ st.session_state.selected_rows = [False] * len(df)
481
+
482
  # Add a "Calculate Relevancy" button at the top
483
  if st.button("Calculate Relevancy for Selected"):
484
  selected_indices = [i for i, selected in enumerate(st.session_state.selected_rows) if selected]
 
495
  for col, header in zip(cols, headers):
496
  col.write(f"**{header}**")
497
 
 
 
 
 
498
  # Display each row
499
+ for i, (index, row) in enumerate(df.iloc[start_idx:end_idx].iterrows()):
500
  cols = st.columns([0.5, 3, 2, 1, 1, 1, 1, 1, 1])
501
 
502
  # Checkbox for row selection