SR05's picture
Update search.py
a167399 verified
raw
history blame
686 Bytes
import pandas as pd
from dataframe import precomputed_df
import streamlit as st
def search_application(application_number):
if precomputed_df is None:
st.error("Data not available. Please try again later.")
return None
# Check for exact match
exact_match = precomputed_df[precomputed_df["Application Number"] == application_number]
if not exact_match.empty:
return exact_match.iloc[0]
# If no exact match, find nearest records
precomputed_df["Difference"] = abs(precomputed_df["Application Number"] - application_number)
nearest_records = precomputed_df.nsmallest(2, "Difference")
return nearest_records.reset_index(drop=True)