Update search.py
Browse files
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 |
-
#
|
24 |
-
|
25 |
-
st.write(df.head()) # Display the data only for debugging purposes
|
26 |
|
27 |
# Convert application number to integer for the nearest calculation
|
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 =
|
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 |
|