Spaces:
Build error
Build error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +10 -14
src/streamlit_app.py
CHANGED
|
@@ -262,16 +262,12 @@ top_10_crimes = df['crm_cd_desc'].value_counts().nlargest(10).index.tolist()
|
|
| 262 |
# Filter the main DataFrame to include only top 10 crimes
|
| 263 |
df_top = df[df['crm_cd_desc'].isin(top_10_crimes)]
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
year_dropdown = ipywidgets.Dropdown(
|
| 272 |
-
options= sorted(df['year'].unique()),
|
| 273 |
-
description='Year:'
|
| 274 |
-
)
|
| 275 |
|
| 276 |
# Create the map.
|
| 277 |
def crime_map(year, crime):
|
|
@@ -289,10 +285,10 @@ def crime_map(year, crime):
|
|
| 289 |
ax.set_xlabel("Longitude")
|
| 290 |
ax.set_ylabel("Latitude")
|
| 291 |
plt.grid(True)
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
#
|
| 295 |
-
|
| 296 |
|
| 297 |
# Define what each menu option does
|
| 298 |
if menu == "Home":
|
|
|
|
| 262 |
# Filter the main DataFrame to include only top 10 crimes
|
| 263 |
df_top = df[df['crm_cd_desc'].isin(top_10_crimes)]
|
| 264 |
|
| 265 |
+
|
| 266 |
+
# Creat dropdown menu
|
| 267 |
+
years = sorted(df['year'].unique())
|
| 268 |
+
year_dropdown = st.selectbox("Year: ", years)
|
| 269 |
+
crime_dropdown = st.selectbox("Crime Type: ", top_10_crimes)
|
| 270 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
# Create the map.
|
| 273 |
def crime_map(year, crime):
|
|
|
|
| 285 |
ax.set_xlabel("Longitude")
|
| 286 |
ax.set_ylabel("Latitude")
|
| 287 |
plt.grid(True)
|
| 288 |
+
st.pyplot(fig)
|
| 289 |
+
|
| 290 |
+
# Call the function with selected values
|
| 291 |
+
crime_map(year_dropdown, crime_dropdown)
|
| 292 |
|
| 293 |
# Define what each menu option does
|
| 294 |
if menu == "Home":
|