nouamanetazi HF staff commited on
Commit
405e170
1 Parent(s): 13a019a

fix search bar

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -220,8 +220,11 @@ def display_dataframe(df, drop_cols, data_url, search_id=True, status=False, for
220
  """Display the dataframe in a table"""
221
  col_1, col_2 = st.columns([1, 1])
222
 
 
 
 
223
  with col_1:
224
- query = st.text_input("🔍 Search for information / بحث عن المعلومات", key=f"query_{uuid.uuid4()}")
225
  with col_2:
226
  if search_id:
227
  id_number = st.number_input(
@@ -230,11 +233,11 @@ def display_dataframe(df, drop_cols, data_url, search_id=True, status=False, for
230
  max_value=len(filtered_df),
231
  value=0,
232
  step=1,
233
- key=f"id_{uuid.uuid4()}",
234
  )
235
  if status:
236
  selected_status = st.selectbox(
237
- "🗓️ Status / حالة", ["all / الكل", "Done / تم", "Planned / مخطط لها"], key=f"status_{uuid.uuid4()}"
238
  )
239
 
240
  if query:
@@ -244,11 +247,11 @@ def display_dataframe(df, drop_cols, data_url, search_id=True, status=False, for
244
  else:
245
  display_df = df
246
 
247
- display_df = display_df.drop(drop_cols, axis=1)
248
-
249
  if search_id and id_number:
250
  display_df = display_df[display_df["id"] == id_number]
251
 
 
 
252
  if status:
253
  target = "Pouvez-vous nous préciser si vous êtes déjà intervenus ou si vous prévoyez de le faire | Tell us if you already made the intervention, or if you're planning to do it"
254
  if selected_status == "Done / تم":
 
220
  """Display the dataframe in a table"""
221
  col_1, col_2 = st.columns([1, 1])
222
 
223
+ # has df's first row
224
+ df_hash = hash(df.iloc[0].to_string())
225
+
226
  with col_1:
227
+ query = st.text_input("🔍 Search for information / بحث عن المعلومات", key=f"query_{df_hash}")
228
  with col_2:
229
  if search_id:
230
  id_number = st.number_input(
 
233
  max_value=len(filtered_df),
234
  value=0,
235
  step=1,
236
+ key=f"id_{df_hash}",
237
  )
238
  if status:
239
  selected_status = st.selectbox(
240
+ "🗓️ Status / حالة", ["all / الكل", "Done / تم", "Planned / مخطط لها"], key=f"status_{df_hash}"
241
  )
242
 
243
  if query:
 
247
  else:
248
  display_df = df
249
 
 
 
250
  if search_id and id_number:
251
  display_df = display_df[display_df["id"] == id_number]
252
 
253
+ display_df = display_df.drop(drop_cols, axis=1)
254
+
255
  if status:
256
  target = "Pouvez-vous nous préciser si vous êtes déjà intervenus ou si vous prévoyez de le faire | Tell us if you already made the intervention, or if you're planning to do it"
257
  if selected_status == "Done / تم":