ralate2 commited on
Commit
1fed836
·
verified ·
1 Parent(s): cc0d12f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -101,25 +101,25 @@ if viz_type == "Complaints Over Time":
101
  # options=block_options,
102
  # key=f"block_select_{viz_type}" # Unique key for each visualization
103
  # )
 
 
 
 
 
 
 
 
104
 
105
  if viz_type in [
106
- "Complaints by Housing Block and Type",
107
  "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"
108
  ]:
109
- block_options = ['All Blocks'] + sorted(data['Housing Block'].unique().tolist())
110
- # Unique key for each viz_type
111
- block_key = f"block_select_{viz_type.replace(' ', '_')}"
112
  selected_block = st.sidebar.selectbox(
113
- "Select Housing Block",
114
- options=block_options,
115
- key=block_key
116
  )
117
- else:
118
- selected_block = 'All Blocks'
119
-
120
- # # Ensuring selected_block is only used if defined
121
- # 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():
122
- # selected_block = 'All Blocks' # Default to 'All Blocks' if no selection made
123
 
124
  # Filtering data based on selected year
125
  if selected_year != 'All Time':
 
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
+ # Dropdown for Housing Block (only show for specific visualizations)
110
+ block_options = ['All Blocks'] + sorted(data['Housing Block'].unique().tolist())
111
+ selected_block = 'All Blocks' # Default value
112
 
113
  if viz_type in [
114
+ "Complaints by Housing Block and Type",
115
  "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"
116
  ]:
117
+ # Show dropdown only when required
 
 
118
  selected_block = st.sidebar.selectbox(
119
+ "Select Housing Block",
120
+ options=block_options,
121
+ key="unique_block_select" # Fixed key to avoid duplicates
122
  )
 
 
 
 
 
 
123
 
124
  # Filtering data based on selected year
125
  if selected_year != 'All Time':