Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -555,15 +555,16 @@ if viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions
|
|
| 555 |
'1700 block', '1800 block', '1900 block', '2000 block', '2100 block',
|
| 556 |
'2200 block', '2300 block', '2400 block', '2500 block', '2600 block',
|
| 557 |
'2700 block', '2800 block', '2900 block', '3000 block', '3100 block',
|
| 558 |
-
'3200 block', '3300 block'
|
| 559 |
-
'3700 block', '3800 block', '3900 block', '4000 block', '4100 block',
|
| 560 |
-
'4200 block', '4300 block', '4400 block', '4500 block', '4600 block',
|
| 561 |
-
'4700 block', '4800 block', '4900 block', '5000 block'
|
| 562 |
]
|
| 563 |
|
| 564 |
# Reordering the index of the pivot table according to the desired order
|
| 565 |
complaint_pivot = complaint_pivot.reindex(desired_order)
|
| 566 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
# Calculating percentages for each complaint type per housing block
|
| 568 |
percentages = complaint_pivot.div(complaint_pivot.sum(axis=1), axis=0) * 100
|
| 569 |
|
|
@@ -573,9 +574,8 @@ if viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions
|
|
| 573 |
|
| 574 |
# Adjusting the x-axis ticks
|
| 575 |
if selected_block != 'All Blocks':
|
| 576 |
-
#
|
| 577 |
-
ax.
|
| 578 |
-
ax.set_xticklabels([])
|
| 579 |
else:
|
| 580 |
# Show every nth label to avoid overcrowding
|
| 581 |
tick_spacing = max(1, len(complaint_pivot) // 10) # Adjust based on the number of blocks
|
|
@@ -621,6 +621,7 @@ if viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions
|
|
| 621 |
""")
|
| 622 |
|
| 623 |
|
|
|
|
| 624 |
|
| 625 |
# Footer
|
| 626 |
st.markdown("---")
|
|
|
|
| 555 |
'1700 block', '1800 block', '1900 block', '2000 block', '2100 block',
|
| 556 |
'2200 block', '2300 block', '2400 block', '2500 block', '2600 block',
|
| 557 |
'2700 block', '2800 block', '2900 block', '3000 block', '3100 block',
|
| 558 |
+
'3200 block', '3300 block'
|
|
|
|
|
|
|
|
|
|
| 559 |
]
|
| 560 |
|
| 561 |
# Reordering the index of the pivot table according to the desired order
|
| 562 |
complaint_pivot = complaint_pivot.reindex(desired_order)
|
| 563 |
|
| 564 |
+
# If a single block is selected, filter for only that block
|
| 565 |
+
if selected_block != 'All Blocks':
|
| 566 |
+
complaint_pivot = complaint_pivot.loc[[selected_block]]
|
| 567 |
+
|
| 568 |
# Calculating percentages for each complaint type per housing block
|
| 569 |
percentages = complaint_pivot.div(complaint_pivot.sum(axis=1), axis=0) * 100
|
| 570 |
|
|
|
|
| 574 |
|
| 575 |
# Adjusting the x-axis ticks
|
| 576 |
if selected_block != 'All Blocks':
|
| 577 |
+
ax.set_xticks([0]) # Only one label
|
| 578 |
+
ax.set_xticklabels([selected_block], rotation=0)
|
|
|
|
| 579 |
else:
|
| 580 |
# Show every nth label to avoid overcrowding
|
| 581 |
tick_spacing = max(1, len(complaint_pivot) // 10) # Adjust based on the number of blocks
|
|
|
|
| 621 |
""")
|
| 622 |
|
| 623 |
|
| 624 |
+
|
| 625 |
|
| 626 |
# Footer
|
| 627 |
st.markdown("---")
|