SR05 commited on
Commit
48a3d3b
1 Parent(s): 033f1de

Update search.py

Browse files
Files changed (1) hide show
  1. search.py +5 -5
search.py CHANGED
@@ -20,17 +20,17 @@ def search_application(user_application_number, df):
20
  # When no record is found, show a warning
21
  st.warning(f"No record found for Application Number: {user_application_number}.")
22
 
23
- # Debugging: Show first few rows only when necessary
24
- st.write("First few rows of the dataset for verification:")
25
- st.write(df.head()) # Display the data only for debugging purposes
26
 
27
  # Convert application number to integer for the nearest calculation
28
- df['Application Number'] = df['Application Number'].astype(int)
 
29
  try:
30
  user_application_number_int = int(user_application_number)
31
 
32
  # Find the nearest pre and post application numbers
33
- df_sorted = df.sort_values(by='Application Number')
34
  pre_number = df_sorted[df_sorted['Application Number'] < user_application_number_int].tail(1)
35
  post_number = df_sorted[df_sorted['Application Number'] > user_application_number_int].head(1)
36
 
 
20
  # When no record is found, show a warning
21
  st.warning(f"No record found for Application Number: {user_application_number}.")
22
 
23
+ # Remove non-numeric rows for the nearest application number calculation
24
+ df_cleaned = df[pd.to_numeric(df['Application Number'], errors='coerce').notnull()]
 
25
 
26
  # Convert application number to integer for the nearest calculation
27
+ df_cleaned['Application Number'] = df_cleaned['Application Number'].astype(int)
28
+
29
  try:
30
  user_application_number_int = int(user_application_number)
31
 
32
  # Find the nearest pre and post application numbers
33
+ df_sorted = df_cleaned.sort_values(by='Application Number')
34
  pre_number = df_sorted[df_sorted['Application Number'] < user_application_number_int].tail(1)
35
  post_number = df_sorted[df_sorted['Application Number'] > user_application_number_int].head(1)
36