Update dataframe.py
Browse files- 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
|
6 |
-
@st.cache_data
|
7 |
-
def
|
8 |
-
|
9 |
-
df
|
10 |
-
|
11 |
-
|
12 |
-
|
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 =
|
|
|
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()
|