ralate2 commited on
Commit
7dea025
·
verified ·
1 Parent(s): 8bbe668

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -496,19 +496,33 @@ elif viz_type == "Complaints by Housing Block and Type":
496
  elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)":
497
  st.subheader("Complaints by Housing Block and Type- Incorporating Suggestions Based on Professor's Feedback")
498
 
499
- # Filtering the data based on the selected year and housing block
500
- filtered_data_time = data # Use filtered_data if date range is not needed
501
- if selected_year != 'All Time':
502
- filtered_data_time = filtered_data_time[filtered_data_time['Year Reported'] == selected_year]
503
-
504
- # Remove the specified blocks (3400 block, 3500 block, 3600 block, ..., 5000 block)
505
  excluded_blocks = [
506
  '3400 block', '3500 block', '3600 block', '3700 block', '3800 block', '3900 block',
507
  '4000 block', '4100 block', '4200 block', '4300 block', '4400 block', '4500 block',
508
  '4600 block', '4700 block', '4800 block', '4900 block', '5000 block'
509
  ]
510
 
511
- # Excluding the blocks from the data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  filtered_data_time = filtered_data_time[~filtered_data_time['Housing Block'].isin(excluded_blocks)]
513
 
514
  # Further filtering by Housing Block (if applicable)
@@ -527,6 +541,9 @@ elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestion
527
  # Ensuring the pivoted data is numeric for plotting
528
  complaint_pivot = complaint_pivot.astype(float)
529
 
 
 
 
530
  # If a specific block is selected, only show that block on the x-axis
531
  if selected_block != 'All Blocks':
532
  complaint_pivot = complaint_pivot.loc[[selected_block]]
@@ -572,6 +589,7 @@ elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestion
572
  """)
573
 
574
 
 
575
  # Footer
576
  st.markdown("---")
577
  st.markdown("Dataset provided by the City of Urbana Open Data Portal.")
 
496
  elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)":
497
  st.subheader("Complaints by Housing Block and Type- Incorporating Suggestions Based on Professor's Feedback")
498
 
499
+ # Define the blocks to be excluded
 
 
 
 
 
500
  excluded_blocks = [
501
  '3400 block', '3500 block', '3600 block', '3700 block', '3800 block', '3900 block',
502
  '4000 block', '4100 block', '4200 block', '4300 block', '4400 block', '4500 block',
503
  '4600 block', '4700 block', '4800 block', '4900 block', '5000 block'
504
  ]
505
 
506
+ # Creating the desired order, excluding unwanted blocks
507
+ desired_order = [
508
+ '1 block', '100 block', '200 block', '300 block', '400 block', '500 block',
509
+ '600 block', '700 block', '800 block', '900 block', '1000 block', '1100 block',
510
+ '1200 block', '1300 block', '1400 block', '1500 block', '1600 block',
511
+ '1700 block', '1800 block', '1900 block', '2000 block', '2100 block',
512
+ '2200 block', '2300 block', '2400 block', '2500 block', '2600 block',
513
+ '2700 block', '2800 block', '2900 block', '3000 block', '3100 block',
514
+ '3200 block', '3300 block', '3500 block', '3600 block', '3700 block',
515
+ '3800 block', '3900 block', '4000 block', '4100 block', '4200 block',
516
+ '4300 block', '4400 block', '4500 block', '4600 block', '4700 block',
517
+ '4800 block', '4900 block', '5000 block'
518
+ ]
519
+
520
+ # Filtering the data based on the selected year and housing block
521
+ filtered_data_time = data # Use filtered_data if date range is not needed
522
+ if selected_year != 'All Time':
523
+ filtered_data_time = filtered_data_time[filtered_data_time['Year Reported'] == selected_year]
524
+
525
+ # Excluding blocks from the data (3400 block, 3500 block, 3600 block, ..., 5000 block)
526
  filtered_data_time = filtered_data_time[~filtered_data_time['Housing Block'].isin(excluded_blocks)]
527
 
528
  # Further filtering by Housing Block (if applicable)
 
541
  # Ensuring the pivoted data is numeric for plotting
542
  complaint_pivot = complaint_pivot.astype(float)
543
 
544
+ # Reordering the index of the pivot table according to the desired order, excluding the unwanted blocks
545
+ complaint_pivot = complaint_pivot.reindex(desired_order)
546
+
547
  # If a specific block is selected, only show that block on the x-axis
548
  if selected_block != 'All Blocks':
549
  complaint_pivot = complaint_pivot.loc[[selected_block]]
 
589
  """)
590
 
591
 
592
+
593
  # Footer
594
  st.markdown("---")
595
  st.markdown("Dataset provided by the City of Urbana Open Data Portal.")