awacke1 commited on
Commit
87dfbb1
·
1 Parent(s): e477a54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -76,10 +76,13 @@ with st.expander("Search by Common Terms 📚"):
76
  if st.button(f"{term}"):
77
  filtered_data = filter_by_keyword(data, term)
78
  st.write(f"Filter on '{term}' 📊")
 
 
79
  with st.sidebar:
80
- # Display each row with a button
 
81
  for idx, row in filtered_data.iterrows():
82
- if st.button(f"Row {idx}", key=f"row_{idx}"):
83
  st.session_state['last_clicked_row'] = idx
84
 
85
  # Check if 'last_clicked_row' is set and in the filtered data
@@ -89,10 +92,10 @@ with st.expander("Search by Common Terms 📚"):
89
  # Extract only the first three columns of the selected row
90
  first_three_columns = selected_row.iloc[:3]
91
 
92
- # Display these columns in the sidebar
93
- st.sidebar.write("Selected Row Details:")
94
  for col in first_three_columns.index:
95
- st.sidebar.write(f"{col}: {first_three_columns[col]}")
96
 
97
  # Concatenate these column values with the question_text
98
  additional_info = ' '.join([f"{col}: {val}" for col, val in first_three_columns.items()])
@@ -102,7 +105,6 @@ with st.expander("Search by Common Terms 📚"):
102
  documentHTML5 = generate_html_with_textarea(full_text)
103
  components.html(documentHTML5, width=1280, height=1024)
104
 
105
-
106
  # Inject HTML5 and JavaScript for styling
107
  st.markdown("""
108
  <style>
 
76
  if st.button(f"{term}"):
77
  filtered_data = filter_by_keyword(data, term)
78
  st.write(f"Filter on '{term}' 📊")
79
+
80
+ # Display the filtered dataframe in the sidebar with buttons for each row
81
  with st.sidebar:
82
+ st.write("Filtered Data:")
83
+ st.dataframe(filtered_data)
84
  for idx, row in filtered_data.iterrows():
85
+ if st.button(f"Select Row {idx}", key=f"row_{idx}"):
86
  st.session_state['last_clicked_row'] = idx
87
 
88
  # Check if 'last_clicked_row' is set and in the filtered data
 
92
  # Extract only the first three columns of the selected row
93
  first_three_columns = selected_row.iloc[:3]
94
 
95
+ # Display these columns in the main area
96
+ st.write("Selected Row Details:")
97
  for col in first_three_columns.index:
98
+ st.write(f"{col}: {first_three_columns[col]}")
99
 
100
  # Concatenate these column values with the question_text
101
  additional_info = ' '.join([f"{col}: {val}" for col, val in first_three_columns.items()])
 
105
  documentHTML5 = generate_html_with_textarea(full_text)
106
  components.html(documentHTML5, width=1280, height=1024)
107
 
 
108
  # Inject HTML5 and JavaScript for styling
109
  st.markdown("""
110
  <style>