Update src/streamlit_app.py
Browse files- src/streamlit_app.py +6 -5
src/streamlit_app.py
CHANGED
|
@@ -16,16 +16,17 @@ st.markdown(
|
|
| 16 |
"""
|
| 17 |
)
|
| 18 |
|
|
|
|
|
|
|
| 19 |
|
| 20 |
@st.cache_data
|
| 21 |
-
def load_data(
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
csv_path = Path(_file_).parent / "crime_data.csv" # ensure file name
|
| 25 |
|
|
|
|
| 26 |
df = load_data()
|
| 27 |
if df.empty:
|
| 28 |
-
st.stop()
|
| 29 |
|
| 30 |
# 3. Data preview
|
| 31 |
st.header("Data Preview")
|
|
|
|
| 16 |
"""
|
| 17 |
)
|
| 18 |
|
| 19 |
+
# 1. Resolve the path to the CSV next to this script
|
| 20 |
+
DATA_PATH = Path(__file__).parent / "crime_data.csv" # /app/src/crime_data.csv
|
| 21 |
|
| 22 |
@st.cache_data
|
| 23 |
+
def load_data():
|
| 24 |
+
return pd.read_csv(DATA_PATH)
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
# 2. Load and early‐exit if missing
|
| 27 |
df = load_data()
|
| 28 |
if df.empty:
|
| 29 |
+
st.stop()
|
| 30 |
|
| 31 |
# 3. Data preview
|
| 32 |
st.header("Data Preview")
|