SR05 commited on
Commit
f609061
1 Parent(s): 3500eef

Update dataframe.py

Browse files
Files changed (1) hide show
  1. dataframe.py +9 -16
dataframe.py CHANGED
@@ -1,21 +1,14 @@
1
  import pandas as pd
2
  from loading_file import df
3
- import streamlit as st
4
 
5
- # Precompute nearest applications
6
- @st.cache_data
7
- def precompute_nearest_applications(df):
8
- """Precomputes the nearest applications for each record in the DataFrame."""
9
- df["Application Number"] = df["Application Number"].astype(int)
10
- df = df.sort_values(by="Application Number").reset_index(drop=True)
11
-
12
- # Add columns for nearest before and after applications
13
- df["Nearest Before"] = df["Application Number"].shift(1)
14
- df["Nearest After"] = df["Application Number"].shift(-1)
15
- df["Nearest Before Decision"] = df["Decision"].shift(1)
16
- df["Nearest After Decision"] = df["Decision"].shift(-1)
17
-
18
- return df
19
 
20
  # Precomputed DataFrame
21
- precomputed_df = precompute_nearest_applications(df)
 
1
  import pandas as pd
2
  from loading_file import df
 
3
 
4
+ # Precompute for faster access during searches
5
+ @st.cache_data(ttl=3600)
6
+ def precompute_dataframe():
7
+ # Sort by application number for better nearest neighbor calculation
8
+ if df is not None:
9
+ df["Application Number"] = df["Application Number"].astype(int)
10
+ return df.sort_values("Application Number").reset_index(drop=True)
11
+ return None
 
 
 
 
 
 
12
 
13
  # Precomputed DataFrame
14
+ precomputed_df = precompute_dataframe()