Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -67,10 +67,17 @@ def load_and_clean_data():
|
|
| 67 |
# Load the data
|
| 68 |
data = load_and_clean_data()
|
| 69 |
|
|
|
|
| 70 |
# Sidebar for controls
|
| 71 |
st.sidebar.header("Dashboard Controls")
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
viz_type = st.sidebar.selectbox("Select Visualization", [
|
| 75 |
"Complaint Types", "Geographic Distribution", "Resolution Status",
|
| 76 |
"Submission Methods", "Complaints by Disposition", "Monthly Trends by Complaint Type",
|
|
@@ -93,8 +100,8 @@ if selected_year != 'All Time':
|
|
| 93 |
else:
|
| 94 |
filtered_data = data
|
| 95 |
|
| 96 |
-
# Further filter by Housing Block
|
| 97 |
-
if
|
| 98 |
filtered_data = filtered_data[filtered_data['Housing Block'] == selected_block]
|
| 99 |
|
| 100 |
# Filter data based on date range (only for Complaints Over Time visualization)
|
|
@@ -104,7 +111,11 @@ if viz_type == "Complaints Over Time":
|
|
| 104 |
(filtered_data['Date Reported'] <= pd.to_datetime(end_date))
|
| 105 |
]
|
| 106 |
else:
|
| 107 |
-
filtered_data_time = filtered_data
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
# Header for selected year
|
| 110 |
st.header(f"Analysis for {'All Time' if selected_year == 'All Time' else selected_year}")
|
|
|
|
| 67 |
# Load the data
|
| 68 |
data = load_and_clean_data()
|
| 69 |
|
| 70 |
+
# Sidebar for controls
|
| 71 |
# Sidebar for controls
|
| 72 |
st.sidebar.header("Dashboard Controls")
|
| 73 |
+
|
| 74 |
+
# Remove the year selection when certain visualizations are selected
|
| 75 |
+
if viz_type not in ["Complaints Over Time", "Complaints by Housing Block and Type"]:
|
| 76 |
+
year_options = ['All Time'] + sorted(data['Year Reported'].unique().tolist())
|
| 77 |
+
selected_year = st.sidebar.selectbox("Select Year", options=year_options)
|
| 78 |
+
else:
|
| 79 |
+
selected_year = 'All Time' # Default to 'All Time' if visualization doesn't require year
|
| 80 |
+
|
| 81 |
viz_type = st.sidebar.selectbox("Select Visualization", [
|
| 82 |
"Complaint Types", "Geographic Distribution", "Resolution Status",
|
| 83 |
"Submission Methods", "Complaints by Disposition", "Monthly Trends by Complaint Type",
|
|
|
|
| 100 |
else:
|
| 101 |
filtered_data = data
|
| 102 |
|
| 103 |
+
# Further filter by Housing Block
|
| 104 |
+
if selected_block != 'All Blocks':
|
| 105 |
filtered_data = filtered_data[filtered_data['Housing Block'] == selected_block]
|
| 106 |
|
| 107 |
# Filter data based on date range (only for Complaints Over Time visualization)
|
|
|
|
| 111 |
(filtered_data['Date Reported'] <= pd.to_datetime(end_date))
|
| 112 |
]
|
| 113 |
else:
|
| 114 |
+
filtered_data_time = filtered_data
|
| 115 |
+
|
| 116 |
+
# Filter data based on selected housing block (only for Complaints by Housing Block visualization)
|
| 117 |
+
if viz_type == "Complaints by Housing Block and Type" and selected_block != 'All Blocks':
|
| 118 |
+
filtered_data_time = filtered_data_time[filtered_data_time['Housing Block'] == selected_block]
|
| 119 |
|
| 120 |
# Header for selected year
|
| 121 |
st.header(f"Analysis for {'All Time' if selected_year == 'All Time' else selected_year}")
|