Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -67,10 +67,16 @@ def load_and_clean_data():
|
|
| 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())
|
|
@@ -78,12 +84,6 @@ if viz_type not in ["Complaints Over Time", "Complaints by Housing Block and Typ
|
|
| 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",
|
| 84 |
-
"Top Complaint Types", "Complaints Over Time", "Complaints by Housing Block and Type"
|
| 85 |
-
])
|
| 86 |
-
|
| 87 |
# Date Range Selector for Complaints Over Time (only show when Complaints Over Time is selected)
|
| 88 |
if viz_type == "Complaints Over Time":
|
| 89 |
start_date = st.sidebar.date_input("Start Date", pd.to_datetime("2020-01-01"))
|
|
@@ -121,6 +121,7 @@ if viz_type == "Complaints by Housing Block and Type" and selected_block != 'All
|
|
| 121 |
st.header(f"Analysis for {'All Time' if selected_year == 'All Time' else selected_year}")
|
| 122 |
|
| 123 |
|
|
|
|
| 124 |
# Display metrics
|
| 125 |
col1, col2 = st.columns(2)
|
| 126 |
with col1:
|
|
|
|
| 67 |
# Load the data
|
| 68 |
data = load_and_clean_data()
|
| 69 |
|
|
|
|
| 70 |
# Sidebar for controls
|
| 71 |
st.sidebar.header("Dashboard Controls")
|
| 72 |
|
| 73 |
+
# First, define the visualization type (viz_type) selection
|
| 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",
|
| 77 |
+
"Top Complaint Types", "Complaints Over Time", "Complaints by Housing Block and Type"
|
| 78 |
+
])
|
| 79 |
+
|
| 80 |
# Remove the year selection when certain visualizations are selected
|
| 81 |
if viz_type not in ["Complaints Over Time", "Complaints by Housing Block and Type"]:
|
| 82 |
year_options = ['All Time'] + sorted(data['Year Reported'].unique().tolist())
|
|
|
|
| 84 |
else:
|
| 85 |
selected_year = 'All Time' # Default to 'All Time' if visualization doesn't require year
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# Date Range Selector for Complaints Over Time (only show when Complaints Over Time is selected)
|
| 88 |
if viz_type == "Complaints Over Time":
|
| 89 |
start_date = st.sidebar.date_input("Start Date", pd.to_datetime("2020-01-01"))
|
|
|
|
| 121 |
st.header(f"Analysis for {'All Time' if selected_year == 'All Time' else selected_year}")
|
| 122 |
|
| 123 |
|
| 124 |
+
|
| 125 |
# Display metrics
|
| 126 |
col1, col2 = st.columns(2)
|
| 127 |
with col1:
|