Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -415,7 +415,6 @@ elif viz_type == "Complaints by Housing Block and Type":
|
|
| 415 |
elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)":
|
| 416 |
st.subheader("Complaints by Housing Block and Type- Incorporating Suggestions Based on Professor's Feedback")
|
| 417 |
|
| 418 |
-
# Filtering the data based on the selected year and housing block
|
| 419 |
# Filtering the data based on the selected year and housing block
|
| 420 |
filtered_data_time = data # Use filtered_data if date range is not needed
|
| 421 |
if selected_year != 'All Time':
|
|
@@ -437,6 +436,23 @@ elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestion
|
|
| 437 |
# Ensuring the pivoted data is numeric for plotting
|
| 438 |
complaint_pivot = complaint_pivot.astype(float)
|
| 439 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
# Calculating percentages for each complaint type per housing block
|
| 441 |
percentages = complaint_pivot.div(complaint_pivot.sum(axis=1), axis=0) * 100
|
| 442 |
|
|
@@ -468,7 +484,7 @@ elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestion
|
|
| 468 |
# Description of the visualization
|
| 469 |
st.write("""
|
| 470 |
**What this visualization shows:**
|
| 471 |
-
This bar chart displays the distribution of complaints by Housing Block and Complaint Type. The data is stacked to show the
|
| 472 |
|
| 473 |
**Why it's interesting:**
|
| 474 |
By analyzing the distribution of complaints by both block and type, organizations can identify specific areas where certain complaint types are more prevalent. This insight helps target interventions and allocate resources more efficiently based on the most common issues in different housing blocks.
|
|
@@ -478,6 +494,7 @@ elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestion
|
|
| 478 |
""")
|
| 479 |
|
| 480 |
|
|
|
|
| 481 |
# Footer
|
| 482 |
st.markdown("---")
|
| 483 |
st.markdown("Dataset provided by the City of Urbana Open Data Portal.")
|
|
|
|
| 415 |
elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)":
|
| 416 |
st.subheader("Complaints by Housing Block and Type- Incorporating Suggestions Based on Professor's Feedback")
|
| 417 |
|
|
|
|
| 418 |
# Filtering the data based on the selected year and housing block
|
| 419 |
filtered_data_time = data # Use filtered_data if date range is not needed
|
| 420 |
if selected_year != 'All Time':
|
|
|
|
| 436 |
# Ensuring the pivoted data is numeric for plotting
|
| 437 |
complaint_pivot = complaint_pivot.astype(float)
|
| 438 |
|
| 439 |
+
# Desired order for the housing blocks
|
| 440 |
+
desired_order = [
|
| 441 |
+
'1 block', '100 block', '200 block', '300 block', '400 block', '500 block',
|
| 442 |
+
'600 block', '700 block', '800 block', '900 block', '1000 block', '1100 block',
|
| 443 |
+
'1200 block', '1300 block', '1400 block', '1500 block', '1600 block',
|
| 444 |
+
'1700 block', '1800 block', '1900 block', '2000 block', '2100 block',
|
| 445 |
+
'2200 block', '2300 block', '2400 block', '2500 block', '2600 block',
|
| 446 |
+
'2700 block', '2800 block', '2900 block', '3000 block', '3100 block',
|
| 447 |
+
'3200 block', '3300 block', '3400 block', '3500 block', '3600 block',
|
| 448 |
+
'3700 block', '3800 block', '3900 block', '4000 block', '4100 block',
|
| 449 |
+
'4200 block', '4300 block', '4400 block', '4500 block', '4600 block',
|
| 450 |
+
'4700 block', '4800 block', '4900 block', '5000 block'
|
| 451 |
+
]
|
| 452 |
+
|
| 453 |
+
# Reordering the index of the pivot table according to the desired order
|
| 454 |
+
complaint_pivot = complaint_pivot.reindex(desired_order)
|
| 455 |
+
|
| 456 |
# Calculating percentages for each complaint type per housing block
|
| 457 |
percentages = complaint_pivot.div(complaint_pivot.sum(axis=1), axis=0) * 100
|
| 458 |
|
|
|
|
| 484 |
# Description of the visualization
|
| 485 |
st.write("""
|
| 486 |
**What this visualization shows:**
|
| 487 |
+
This bar chart displays the distribution of complaints by Housing Block and Complaint Type. The data is stacked to show the percentage of complaints per block, categorized by type. This allows for a quick comparison of the most common complaint types across different housing blocks. While the percentages may be challenging to read when data for all blocks is displayed, they become more valuable and easier to interpret when a single block is selected. Selecting a specific block allows for clearer insights into the proportion of each complaint type within that block, providing more actionable information.
|
| 488 |
|
| 489 |
**Why it's interesting:**
|
| 490 |
By analyzing the distribution of complaints by both block and type, organizations can identify specific areas where certain complaint types are more prevalent. This insight helps target interventions and allocate resources more efficiently based on the most common issues in different housing blocks.
|
|
|
|
| 494 |
""")
|
| 495 |
|
| 496 |
|
| 497 |
+
|
| 498 |
# Footer
|
| 499 |
st.markdown("---")
|
| 500 |
st.markdown("Dataset provided by the City of Urbana Open Data Portal.")
|