Spaces:
Build error
Build error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +2 -3
src/streamlit_app.py
CHANGED
|
@@ -246,7 +246,6 @@ top_10_crimes = df['crm_cd_desc'].value_counts().nlargest(10).index.tolist()
|
|
| 246 |
# Filter the main DataFrame to include only top 10 crimes
|
| 247 |
df_top = df[df['crm_cd_desc'].isin(top_10_crimes)]
|
| 248 |
|
| 249 |
-
|
| 250 |
# Creat dropdown menu
|
| 251 |
years = sorted(df['year'].unique())
|
| 252 |
year_dropdown = st.selectbox("Year: ", years)
|
|
@@ -256,6 +255,7 @@ crime_dropdown = st.selectbox("Crime Type: ", top_10_crimes)
|
|
| 256 |
df_filtered = df[(df['year'] == year_dropdown) & (df['crm_cd_desc'] == crime_dropdown)].sample(n=300, random_state=1)
|
| 257 |
|
| 258 |
# Create the new folium map to make the map more interactive.
|
|
|
|
| 259 |
new_map = folium.Map(location=[df_filtered['lat'].mean(), df_filtered['lon'].mean()], zoom_start=10)
|
| 260 |
|
| 261 |
# Add county boundary
|
|
@@ -282,8 +282,7 @@ folium.GeoJson(geojson_data, name="County Boundaries").add_to(new_map)
|
|
| 282 |
# # Call the function with selected values
|
| 283 |
# crime_map(year_dropdown, crime_dropdown)
|
| 284 |
|
| 285 |
-
#
|
| 286 |
-
# Method comes from: https://folium.streamlit.app/.
|
| 287 |
for _, row in df_filtered.iterrows():
|
| 288 |
folium.CircleMarker(
|
| 289 |
location=[row['lat'], row['lon']],
|
|
|
|
| 246 |
# Filter the main DataFrame to include only top 10 crimes
|
| 247 |
df_top = df[df['crm_cd_desc'].isin(top_10_crimes)]
|
| 248 |
|
|
|
|
| 249 |
# Creat dropdown menu
|
| 250 |
years = sorted(df['year'].unique())
|
| 251 |
year_dropdown = st.selectbox("Year: ", years)
|
|
|
|
| 255 |
df_filtered = df[(df['year'] == year_dropdown) & (df['crm_cd_desc'] == crime_dropdown)].sample(n=300, random_state=1)
|
| 256 |
|
| 257 |
# Create the new folium map to make the map more interactive.
|
| 258 |
+
# Method comes from: https://folium.streamlit.app/.
|
| 259 |
new_map = folium.Map(location=[df_filtered['lat'].mean(), df_filtered['lon'].mean()], zoom_start=10)
|
| 260 |
|
| 261 |
# Add county boundary
|
|
|
|
| 282 |
# # Call the function with selected values
|
| 283 |
# crime_map(year_dropdown, crime_dropdown)
|
| 284 |
|
| 285 |
+
# Using for-loop to add the crime points
|
|
|
|
| 286 |
for _, row in df_filtered.iterrows():
|
| 287 |
folium.CircleMarker(
|
| 288 |
location=[row['lat'], row['lon']],
|