wanwanlin0521 commited on
Commit
02f01ce
·
verified ·
1 Parent(s): 30fc316

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +0 -22
src/streamlit_app.py CHANGED
@@ -202,28 +202,6 @@ This heatmap shows the frequency of the top 10 crimes from 2020 to 2025. The x a
202
  """)
203
 
204
 
205
- # -------------------------------- ???????????????? --------------------------------
206
- # Count the crime type and list out the top 10 crime type that have the most cases.
207
- top_crimes = df['crm_cd_desc'].value_counts().nlargest(10).index
208
- df = df[df['year'] != 2025]
209
- df_top = df[df['crm_cd_desc'].isin(top_crimes)]
210
-
211
- # Group by crime type and year.
212
- stacked_year_df = df_top.groupby(['year', 'crm_cd_desc']).size().reset_index(name='count')
213
-
214
- # Create the stacked bar chart.
215
- alt.Chart(stacked_year_df).mark_bar().encode(
216
- x=alt.X('year:O', title='Year'),
217
- y=alt.Y('count:Q', stack='zero', title='Number of Incidents'),
218
- color=alt.Color('crm_cd_desc:N', title='Crime Type'),
219
- tooltip=['year', 'crm_cd_desc', 'count']
220
- ).properties(
221
- width=600,
222
- height=400,
223
- title='Stacked Crime Composition by Year (Top 10 Crime Types)'
224
- )
225
-
226
-
227
  # -------------------------------- Plot 3: Line Chart --------------------------------
228
  df = df[df['year'] != 2025] # 2025 is not end, so the trend can't be see
229
 
 
202
  """)
203
 
204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  # -------------------------------- Plot 3: Line Chart --------------------------------
206
  df = df[df['year'] != 2025] # 2025 is not end, so the trend can't be see
207