poemsforaphrodite commited on
Commit
0b016f9
1 Parent(s): 474ca04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -633,7 +633,7 @@ def show_tabular_data(df, co, country_code):
633
  if pd.isna(df.iloc[index]['relevancy_score']) or df.iloc[index]['relevancy_score'] == 0:
634
  df.iloc[index, df.columns.get_loc('relevancy_score')] = calculate_single_relevancy(df.iloc[index])
635
  st.success(f"Calculated relevancy scores for {len(selected_indices)} selected rows.")
636
- st.experimental_rerun()
637
 
638
  # Display column headers
639
  cols = st.columns([0.5, 3, 2, 1, 1, 1, 1, 1, 1])
@@ -645,10 +645,10 @@ def show_tabular_data(df, co, country_code):
645
  for i, row in enumerate(df.iloc[start_idx:end_idx].itertuples(), start=start_idx):
646
  cols = st.columns([0.5, 3, 2, 1, 1, 1, 1, 1, 1])
647
 
648
- # Checkbox for row selection
649
- cols[0].checkbox("", key=f"select_{i}", value=st.session_state.selected_rows[i],
650
  on_change=lambda idx=i: setattr(st.session_state, 'selected_rows',
651
- [True if j == idx else x for j, x in enumerate(st.session_state.selected_rows)]))
652
 
653
  # Truncate and make the URL clickable
654
  truncated_url = row.page[:30] + '...' if len(row.page) > 30 else row.page
@@ -677,7 +677,7 @@ def show_tabular_data(df, co, country_code):
677
  if st.session_state[competitor_state_key]:
678
  st.write(f"Competitor Analysis for: {row.query}")
679
  with st.spinner('Analyzing competitors...'):
680
- results_df = analyze_competitors(row._asdict(), co, country_code=country_code)
681
 
682
  # Sort the results by Position in ascending order
683
  results_df = results_df.sort_values('Position', ascending=True).reset_index(drop=True)
@@ -717,11 +717,11 @@ def show_tabular_data(df, co, country_code):
717
  st.warning("Your page's relevancy score is in the lower half of the results. Consider optimizing your content.")
718
  else:
719
  st.error(f"Our page '{row.page}' is not in the results. This indicates an error in fetching or processing the page.")
720
-
721
  if compare_state_key not in st.session_state:
722
  st.session_state[compare_state_key] = False
723
 
724
- if st.button("Compare Your Relevancy Score to the Page In First Place", key=compare_button_key):
725
  st.session_state[compare_state_key] = True
726
 
727
  if st.session_state[compare_state_key]:
 
633
  if pd.isna(df.iloc[index]['relevancy_score']) or df.iloc[index]['relevancy_score'] == 0:
634
  df.iloc[index, df.columns.get_loc('relevancy_score')] = calculate_single_relevancy(df.iloc[index])
635
  st.success(f"Calculated relevancy scores for {len(selected_indices)} selected rows.")
636
+ st.rerun()
637
 
638
  # Display column headers
639
  cols = st.columns([0.5, 3, 2, 1, 1, 1, 1, 1, 1])
 
645
  for i, row in enumerate(df.iloc[start_idx:end_idx].itertuples(), start=start_idx):
646
  cols = st.columns([0.5, 3, 2, 1, 1, 1, 1, 1, 1])
647
 
648
+ # Checkbox for row selection with a label
649
+ cols[0].checkbox("Select", key=f"select_{i}", value=st.session_state.selected_rows[i],
650
  on_change=lambda idx=i: setattr(st.session_state, 'selected_rows',
651
+ [True if j == idx else x for j, x in enumerate(st.session_state.selected_rows)]))
652
 
653
  # Truncate and make the URL clickable
654
  truncated_url = row.page[:30] + '...' if len(row.page) > 30 else row.page
 
677
  if st.session_state[competitor_state_key]:
678
  st.write(f"Competitor Analysis for: {row.query}")
679
  with st.spinner('Analyzing competitors...'):
680
+ results_df = analyze_competitors(row, co, country_code=country_code)
681
 
682
  # Sort the results by Position in ascending order
683
  results_df = results_df.sort_values('Position', ascending=True).reset_index(drop=True)
 
717
  st.warning("Your page's relevancy score is in the lower half of the results. Consider optimizing your content.")
718
  else:
719
  st.error(f"Our page '{row.page}' is not in the results. This indicates an error in fetching or processing the page.")
720
+
721
  if compare_state_key not in st.session_state:
722
  st.session_state[compare_state_key] = False
723
 
724
+ if cols[8].button("Compare Your Relevancy Score to the Page In First Place", key=compare_button_key):
725
  st.session_state[compare_state_key] = True
726
 
727
  if st.session_state[compare_state_key]: