ralate2 commited on
Commit
ec8d9e4
·
verified ·
1 Parent(s): ab044b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -13
app.py CHANGED
@@ -81,31 +81,40 @@ viz_type = st.sidebar.selectbox("Select Visualization", [
81
  "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"
82
  ], key="viz_type_select")
83
 
84
- # Remove the year selection when certain visualizations are selected
 
 
 
 
 
 
85
  if viz_type not in ["Complaints Over Time", "Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"]:
86
  year_options = ['All Time'] + sorted(data['Year Reported'].unique().tolist())
87
  selected_year = st.sidebar.selectbox("Select Year", options=year_options, key="year_select")
88
  else:
89
- selected_year = 'All Time' # Default to 'All Time' if visualization doesn't require year
90
 
91
  # Date Range Selector for Complaints Over Time (only show when Complaints Over Time is selected)
92
  if viz_type == "Complaints Over Time":
93
  start_date = st.sidebar.date_input("Start Date", pd.to_datetime("2020-01-01"), key="start_date")
94
  end_date = st.sidebar.date_input("End Date", pd.to_datetime("2024-12-31"), key="end_date")
95
 
96
- # Dropdown for Housing Block (only show when Complaints by Housing Block and Type or the updated version is selected)
97
- if viz_type in ["Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"]:
98
- block_options = ['All Blocks'] + sorted(data['Housing Block'].unique().tolist())
99
- selected_block = st.sidebar.selectbox(
100
- "Select Housing Block",
101
- options=block_options,
102
- key=f"block_select_{viz_type}" # Unique key for each visualization
103
- )
104
 
105
- # Ensuring selected_block is only used if defined
106
- if viz_type in ["Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"] and 'selected_block' not in locals():
107
- selected_block = 'All Blocks' # Default to 'All Blocks' if no selection made
108
 
 
 
 
109
 
110
  # Filtering the data based on selected year
111
  filtered_data_time = data # Use filtered_data if date range is not needed
 
81
  "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"
82
  ], key="viz_type_select")
83
 
84
+ # # Remove the year selection when certain visualizations are selected
85
+ # if viz_type not in ["Complaints Over Time", "Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"]:
86
+ # year_options = ['All Time'] + sorted(data['Year Reported'].unique().tolist())
87
+ # selected_year = st.sidebar.selectbox("Select Year", options=year_options, key="year_select")
88
+ # else:
89
+ # selected_year = 'All Time' # Default to 'All Time' if visualization doesn't require year
90
+
91
  if viz_type not in ["Complaints Over Time", "Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"]:
92
  year_options = ['All Time'] + sorted(data['Year Reported'].unique().tolist())
93
  selected_year = st.sidebar.selectbox("Select Year", options=year_options, key="year_select")
94
  else:
95
+ selected_year = 'All Time'
96
 
97
  # Date Range Selector for Complaints Over Time (only show when Complaints Over Time is selected)
98
  if viz_type == "Complaints Over Time":
99
  start_date = st.sidebar.date_input("Start Date", pd.to_datetime("2020-01-01"), key="start_date")
100
  end_date = st.sidebar.date_input("End Date", pd.to_datetime("2024-12-31"), key="end_date")
101
 
102
+ # # Dropdown for Housing Block (only show when Complaints by Housing Block and Type or the updated version is selected)
103
+ # if viz_type in ["Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"]:
104
+ # block_options = ['All Blocks'] + sorted(data['Housing Block'].unique().tolist())
105
+ # selected_block = st.sidebar.selectbox(
106
+ # "Select Housing Block",
107
+ # options=block_options,
108
+ # key=f"block_select_{viz_type}" # Unique key for each visualization
109
+ # )
110
 
111
+ # # Ensuring selected_block is only used if defined
112
+ # if viz_type in ["Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"] and 'selected_block' not in locals():
113
+ # selected_block = 'All Blocks' # Default to 'All Blocks' if no selection made
114
 
115
+ if viz_type in ["Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"]:
116
+ block_options = ['All Blocks'] + sorted(data['Housing Block'].unique().tolist())
117
+ selected_block = st.sidebar.selectbox("Select Housing Block", options=block_options, key=f"block_select_{viz_type}")
118
 
119
  # Filtering the data based on selected year
120
  filtered_data_time = data # Use filtered_data if date range is not needed