Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -277,7 +277,7 @@ def main():
|
|
| 277 |
df['Weather'] = 'Unknown'
|
| 278 |
|
| 279 |
# Create tabs for different visualizations
|
| 280 |
-
tab1, tab2, tab3, tab4 = st.tabs(["Crash Statistics", "Crash Map", "Crash Trend", "Crash Injuries/Fatalities","
|
| 281 |
|
| 282 |
with tab1:
|
| 283 |
# Age group selection
|
|
@@ -351,7 +351,28 @@ def main():
|
|
| 351 |
injuries_fatalities_chart = create_injuries_fatalities_chart(df, unit_type)
|
| 352 |
st.altair_chart(injuries_fatalities_chart, use_container_width=True)
|
| 353 |
st.markdown("#### TODO: add write-up for this 5th chart.")
|
| 354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
|
| 356 |
if __name__ == "__main__":
|
| 357 |
main()
|
|
|
|
| 277 |
df['Weather'] = 'Unknown'
|
| 278 |
|
| 279 |
# Create tabs for different visualizations
|
| 280 |
+
tab1, tab2, tab3, tab4, tab5 = st.tabs(["Crash Statistics", "Crash Map", "Crash Trend", "Crash Injuries/Fatalities","Distribution by Category"])
|
| 281 |
|
| 282 |
with tab1:
|
| 283 |
# Age group selection
|
|
|
|
| 351 |
injuries_fatalities_chart = create_injuries_fatalities_chart(df, unit_type)
|
| 352 |
st.altair_chart(injuries_fatalities_chart, use_container_width=True)
|
| 353 |
st.markdown("#### TODO: add write-up for this 5th chart.")
|
| 354 |
+
|
| 355 |
+
with tab5:
|
| 356 |
+
# Dropdown for category selection
|
| 357 |
+
categories = [
|
| 358 |
+
'Collisionmanner',
|
| 359 |
+
'Lightcondition',
|
| 360 |
+
'Weather',
|
| 361 |
+
'SurfaceCondition',
|
| 362 |
+
'AlcoholUse_Drv1',
|
| 363 |
+
'Gender_Drv1',
|
| 364 |
+
]
|
| 365 |
+
selected_category = st.selectbox("Select Category:", categories)
|
| 366 |
+
|
| 367 |
+
# Dropdown for year selection
|
| 368 |
+
years = ['All Years'] + sorted(df['Year'].dropna().unique().astype(int).tolist())
|
| 369 |
+
selected_year = st.selectbox("Select Year:", years)
|
| 370 |
+
|
| 371 |
+
# Generate and display the distribution chart
|
| 372 |
+
st.markdown(f"### Distribution of Incidents by {selected_category}")
|
| 373 |
+
distribution_chart = create_category_distribution_chart(df, selected_category, selected_year)
|
| 374 |
+
st.plotly_chart(distribution_chart, use_container_width=True)
|
| 375 |
+
|
| 376 |
|
| 377 |
if __name__ == "__main__":
|
| 378 |
main()
|