Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ st.markdown("""
|
|
| 31 |
}
|
| 32 |
div[data-testid="stMetric"]:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
|
| 33 |
div[data-testid="stMetricValue"] { color: #0f172a !important; font-weight: 800 !important; font-size: 2rem !important; }
|
| 34 |
-
div[data-testid="stMetricLabel"] { color: #
|
| 35 |
|
| 36 |
/* DATAFRAME */
|
| 37 |
div[data-testid="stDataFrame"] { border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
|
@@ -39,6 +39,9 @@ st.markdown("""
|
|
| 39 |
background: linear-gradient(to bottom, #f8fafc, #f1f5f9) !important;
|
| 40 |
color: #0f172a !important; font-weight: 700 !important; border-bottom: 2px solid #cbd5e1 !important;
|
| 41 |
}
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
/* SIDEBAR */
|
| 44 |
[data-testid="stSidebar"] { background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%); border-right: 1px solid #334155; }
|
|
@@ -47,6 +50,7 @@ st.markdown("""
|
|
| 47 |
|
| 48 |
/* UI ELEMENTS */
|
| 49 |
h1 { background: linear-gradient(135deg, #0f172a 0%, #334155 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 800 !important; }
|
|
|
|
| 50 |
.status-badge { display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 9999px; font-size: 12px; font-weight: 700; text-transform: uppercase; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
| 51 |
.bg-red { background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); color: #991b1b; }
|
| 52 |
.bg-green { background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%); color: #166534; }
|
|
@@ -144,8 +148,7 @@ def load_data():
|
|
| 144 |
try:
|
| 145 |
df = pd.read_csv('analyzed_aadhaar_data.csv')
|
| 146 |
except FileNotFoundError:
|
| 147 |
-
|
| 148 |
-
return pd.DataFrame()
|
| 149 |
|
| 150 |
if 'date' in df.columns: df['date'] = pd.to_datetime(df['date'])
|
| 151 |
|
|
@@ -250,7 +253,7 @@ if not filtered_df.empty:
|
|
| 250 |
m4.metric("Avg Risk", f"{filtered_df['RISK_SCORE'].mean():.1f}/100" if not filtered_df.empty else "0", border=True)
|
| 251 |
m5.metric("Weekend Spikes", f"{len(filtered_df[(filtered_df['is_weekend'] == 1) & (filtered_df['RISK_SCORE'] > 70)])}", delta="Suspicious", delta_color="off", border=True)
|
| 252 |
else:
|
| 253 |
-
st.
|
| 254 |
|
| 255 |
st.markdown("##")
|
| 256 |
|
|
@@ -274,7 +277,7 @@ with tab_map:
|
|
| 274 |
|
| 275 |
fig.update_layout(margin={"r":0,"t":40,"l":0,"b":0})
|
| 276 |
st.plotly_chart(fig, use_container_width=True)
|
| 277 |
-
else: st.
|
| 278 |
|
| 279 |
with c_det:
|
| 280 |
st.subheader("🔥 Top Hotspots")
|
|
@@ -292,7 +295,7 @@ with tab_list:
|
|
| 292 |
st.download_button("📥 Export CSV", data=csv, file_name="stark_priority.csv", mime="text/csv", type="primary")
|
| 293 |
st.dataframe(targets[['date', 'state', 'district', 'pincode', 'enrol_adult', 'total_activity', 'RISK_SCORE']],
|
| 294 |
column_config={"RISK_SCORE": st.column_config.ProgressColumn("Risk", format="%.1f%%", min_value=0, max_value=100)}, use_container_width=True, hide_index=True)
|
| 295 |
-
else: st.
|
| 296 |
|
| 297 |
with tab_charts:
|
| 298 |
c1, c2 = st.columns(2)
|
|
|
|
| 31 |
}
|
| 32 |
div[data-testid="stMetric"]:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
|
| 33 |
div[data-testid="stMetricValue"] { color: #0f172a !important; font-weight: 800 !important; font-size: 2rem !important; }
|
| 34 |
+
div[data-testid="stMetricLabel"] { color: #334155 !important; font-weight: 600 !important; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
|
| 35 |
|
| 36 |
/* DATAFRAME */
|
| 37 |
div[data-testid="stDataFrame"] { border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
|
|
|
| 39 |
background: linear-gradient(to bottom, #f8fafc, #f1f5f9) !important;
|
| 40 |
color: #0f172a !important; font-weight: 700 !important; border-bottom: 2px solid #cbd5e1 !important;
|
| 41 |
}
|
| 42 |
+
div[data-testid="stDataFrame"] div[role="grid"] {
|
| 43 |
+
color: #334155 !important;
|
| 44 |
+
}
|
| 45 |
|
| 46 |
/* SIDEBAR */
|
| 47 |
[data-testid="stSidebar"] { background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%); border-right: 1px solid #334155; }
|
|
|
|
| 50 |
|
| 51 |
/* UI ELEMENTS */
|
| 52 |
h1 { background: linear-gradient(135deg, #0f172a 0%, #334155 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 800 !important; }
|
| 53 |
+
h2, h3 { color: #0f172a !important; }
|
| 54 |
.status-badge { display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 9999px; font-size: 12px; font-weight: 700; text-transform: uppercase; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
| 55 |
.bg-red { background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); color: #991b1b; }
|
| 56 |
.bg-green { background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%); color: #166534; }
|
|
|
|
| 148 |
try:
|
| 149 |
df = pd.read_csv('analyzed_aadhaar_data.csv')
|
| 150 |
except FileNotFoundError:
|
| 151 |
+
return pd.DataFrame() # Return empty to trigger external error check
|
|
|
|
| 152 |
|
| 153 |
if 'date' in df.columns: df['date'] = pd.to_datetime(df['date'])
|
| 154 |
|
|
|
|
| 253 |
m4.metric("Avg Risk", f"{filtered_df['RISK_SCORE'].mean():.1f}/100" if not filtered_df.empty else "0", border=True)
|
| 254 |
m5.metric("Weekend Spikes", f"{len(filtered_df[(filtered_df['is_weekend'] == 1) & (filtered_df['RISK_SCORE'] > 70)])}", delta="Suspicious", delta_color="off", border=True)
|
| 255 |
else:
|
| 256 |
+
st.error("❌ Critical Error: 'analyzed_aadhaar_data.csv' not found. Please upload the data file.")
|
| 257 |
|
| 258 |
st.markdown("##")
|
| 259 |
|
|
|
|
| 277 |
|
| 278 |
fig.update_layout(margin={"r":0,"t":40,"l":0,"b":0})
|
| 279 |
st.plotly_chart(fig, use_container_width=True)
|
| 280 |
+
else: st.info("Waiting for data...")
|
| 281 |
|
| 282 |
with c_det:
|
| 283 |
st.subheader("🔥 Top Hotspots")
|
|
|
|
| 295 |
st.download_button("📥 Export CSV", data=csv, file_name="stark_priority.csv", mime="text/csv", type="primary")
|
| 296 |
st.dataframe(targets[['date', 'state', 'district', 'pincode', 'enrol_adult', 'total_activity', 'RISK_SCORE']],
|
| 297 |
column_config={"RISK_SCORE": st.column_config.ProgressColumn("Risk", format="%.1f%%", min_value=0, max_value=100)}, use_container_width=True, hide_index=True)
|
| 298 |
+
else: st.info("Waiting for data...")
|
| 299 |
|
| 300 |
with tab_charts:
|
| 301 |
c1, c2 = st.columns(2)
|