ralate2 commited on
Commit
b01c1d2
·
verified ·
1 Parent(s): 69bfce8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -288,8 +288,9 @@ elif viz_type == "Complaints Over Time":
288
  elif viz_type == "Complaints by Housing Block and Type":
289
  st.subheader("Complaints by Housing Block and Type")
290
 
 
291
  if selected_block != 'All Blocks':
292
- complaint_pivot = filtered_data_time.pivot_table(
293
  index='Housing Block',
294
  columns='Type of Complaint',
295
  values='Disposition',
@@ -297,7 +298,7 @@ elif viz_type == "Complaints by Housing Block and Type":
297
  fill_value=0
298
  )
299
  else:
300
- complaint_pivot = filtered_data.pivot_table(
301
  index='Housing Block',
302
  columns='Type of Complaint',
303
  values='Disposition',
@@ -305,9 +306,13 @@ elif viz_type == "Complaints by Housing Block and Type":
305
  fill_value=0
306
  )
307
 
 
 
 
308
  fig = complaint_pivot.plot(kind='bar', stacked=True, colormap='inferno', figsize=(10, 6)).get_figure()
309
  st.pyplot(fig)
310
 
 
311
  st.write("""
312
  **What this visualization shows:**
313
  This line chart shows the trend of complaints over time, displaying the number of complaints reported for each day. It helps identify patterns, peaks, and trends in the complaints data.
 
288
  elif viz_type == "Complaints by Housing Block and Type":
289
  st.subheader("Complaints by Housing Block and Type")
290
 
291
+ # Filter the data based on the selected block
292
  if selected_block != 'All Blocks':
293
+ complaint_pivot = filtered_data_time[filtered_data_time['Housing Block'] == selected_block].pivot_table(
294
  index='Housing Block',
295
  columns='Type of Complaint',
296
  values='Disposition',
 
298
  fill_value=0
299
  )
300
  else:
301
+ complaint_pivot = filtered_data_time.pivot_table(
302
  index='Housing Block',
303
  columns='Type of Complaint',
304
  values='Disposition',
 
306
  fill_value=0
307
  )
308
 
309
+ # Ensure the pivoted data is numeric for plotting
310
+ complaint_pivot = complaint_pivot.astype(float)
311
+
312
  fig = complaint_pivot.plot(kind='bar', stacked=True, colormap='inferno', figsize=(10, 6)).get_figure()
313
  st.pyplot(fig)
314
 
315
+
316
  st.write("""
317
  **What this visualization shows:**
318
  This line chart shows the trend of complaints over time, displaying the number of complaints reported for each day. It helps identify patterns, peaks, and trends in the complaints data.