ralate2 commited on
Commit
874a4ac
·
verified ·
1 Parent(s): 8666827

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -61
app.py CHANGED
@@ -71,64 +71,6 @@ def load_and_clean_data():
71
  # Loading the data
72
  data = load_and_clean_data()
73
 
74
-
75
- # # Sidebar for controls
76
- # st.sidebar.header("Dashboard Controls")
77
-
78
- # # Defining the visualization type (viz_type) selection
79
- # viz_type = st.sidebar.selectbox("Select Visualization", [
80
- # "Complaint Types", "Geographic Distribution", "Complaints by Disposition", "Submission Methods",
81
- # "Monthly Trends by Complaint Type", "Complaints Over Time", "Complaints by Housing Block and Type",
82
- # "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"
83
- # ])
84
-
85
- # # Removing the year selection when certain visualizations are selected
86
- # 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)"]:
87
- # year_options = ['All Time'] + sorted(data['Year Reported'].unique().tolist())
88
- # selected_year = st.sidebar.selectbox("Select Year", options=year_options, key="year_select")
89
- # else:
90
- # selected_year = 'All Time' # Default to 'All Time' if visualization doesn't require year
91
-
92
- # # Date Range Selector for Complaints Over Time (only show when Complaints Over Time is selected)
93
- # if viz_type == "Complaints Over Time":
94
- # start_date = st.sidebar.date_input("Start Date", pd.to_datetime("2020-01-01"), key="start_date")
95
- # end_date = st.sidebar.date_input("End Date", pd.to_datetime("2024-12-31"), key="end_date")
96
-
97
- # # Dropdown for Housing Block (only show when Complaints by Housing Block and Type or the updated version is selected)
98
- # if viz_type in ["Complaints by Housing Block and Type", "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)"]:
99
- # block_options = ['All Blocks'] + sorted(data['Housing Block'].unique().tolist())
100
- # selected_block = st.sidebar.selectbox("Select Housing Block", options=block_options, key="block_select")
101
-
102
- # # Ensuring selected_block is only used if defined
103
- # 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():
104
- # selected_block = 'All Blocks' # Default to 'All Blocks' if no selection made
105
-
106
- # # Filtering data based on selected year
107
- # if selected_year != 'All Time':
108
- # filtered_data = data[data['Year Reported'] == selected_year]
109
- # else:
110
- # filtered_data = data
111
-
112
- # # Further filtering by Housing Block
113
- # if 'selected_block' in locals() and selected_block != 'All Blocks':
114
- # filtered_data = filtered_data[filtered_data['Housing Block'] == selected_block]
115
-
116
- # # Filtering data based on date range (only for Complaints Over Time visualization)
117
- # if viz_type == "Complaints Over Time":
118
- # filtered_data_time = filtered_data[
119
- # (filtered_data['Date Reported'] >= pd.to_datetime(start_date)) &
120
- # (filtered_data['Date Reported'] <= pd.to_datetime(end_date))
121
- # ]
122
- # else:
123
- # filtered_data_time = filtered_data
124
-
125
- # # Filtering data based on selected housing block (only for Complaints by Housing Block and the updated version)
126
- # 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 != 'All Blocks':
127
- # filtered_data_time = filtered_data_time[filtered_data_time['Housing Block'] == selected_block]
128
-
129
- # # Header for selected year
130
- # st.header(f"Analysis for {'All Time' if selected_year == 'All Time' else selected_year}")
131
-
132
  # Sidebar for controls
133
  st.sidebar.header("Dashboard Controls")
134
 
@@ -316,7 +258,7 @@ elif viz_type == "Submission Methods":
316
  # Write-up
317
  st.write("""
318
  **What this visualization shows:**
319
- This chart shows the number of complaints submitted via different methods, such as email, phone, online form, etc., with a focus on the top 5 submission methods.
320
 
321
  **Why it's interesting:**
322
  By analyzing submission methods, we can understand how users prefer to submit complaints. This insight helps in focusing efforts on improving the most used channels, ensuring better user engagement.
@@ -554,6 +496,7 @@ elif viz_type == "Complaints by Housing Block and Type":
554
  # **Color Scheme:**
555
  # The 'inferno' color palette is used to represent different complaint types, with darker shades indicating a higher frequency of complaints. The stacked bar chart makes it easy to compare the distribution of complaints by block and type.
556
  # """)
 
557
 
558
  elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)":
559
  st.subheader("Complaints by Housing Block and Type - Incorporating Suggestions Based on Professor's Feedback")
@@ -645,7 +588,7 @@ elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestion
645
  # Description of the visualization
646
  st.write("""
647
  **What this visualization shows:**
648
- This bar chart displays the distribution of complaints by Housing Block and Complaint Type. The data is stacked to show the total number of complaints per block, categorized by type. This allows for a quick comparison of the most common complaint types across different housing blocks.
649
 
650
  **Why it's interesting:**
651
  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.
@@ -656,4 +599,4 @@ elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestion
656
 
657
  # Footer
658
  st.markdown("---")
659
- st.markdown("Dataset provided by the City of Urbana Open Data Portal.")
 
71
  # Loading the data
72
  data = load_and_clean_data()
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  # Sidebar for controls
75
  st.sidebar.header("Dashboard Controls")
76
 
 
258
  # Write-up
259
  st.write("""
260
  **What this visualization shows:**
261
+ This chart shows the number of complaints submitted via different methods, such as email, phone, online form, etc., with a focus on the top 5 submission methods. If one wishes to see the percentage wise distribution, pie chart option can be selected from the interactivity option provided.
262
 
263
  **Why it's interesting:**
264
  By analyzing submission methods, we can understand how users prefer to submit complaints. This insight helps in focusing efforts on improving the most used channels, ensuring better user engagement.
 
496
  # **Color Scheme:**
497
  # The 'inferno' color palette is used to represent different complaint types, with darker shades indicating a higher frequency of complaints. The stacked bar chart makes it easy to compare the distribution of complaints by block and type.
498
  # """)
499
+ # In the above code , We incorporated all of the professor's suggestions and refined the chart to make it more useful for analysis while ensuring good aesthetics. Given that the data from block 3400 onwards is very sparse, we decided to exclude these records. This adjustment helped focus the visualization on the more relevant data, providing clearer insights and improving its overall effectiveness for analysis.
500
 
501
  elif viz_type == "Complaints by Housing Block and Type (Incorporating Suggestions Based on Professor's Feedback)":
502
  st.subheader("Complaints by Housing Block and Type - Incorporating Suggestions Based on Professor's Feedback")
 
588
  # Description of the visualization
589
  st.write("""
590
  **What this visualization shows:**
591
+ This bar chart displays the distribution of complaints by Housing Block and Complaint Type. The data is stacked to show the percentage distribution 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.
592
 
593
  **Why it's interesting:**
594
  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.
 
599
 
600
  # Footer
601
  st.markdown("---")
602
+ st.markdown("Dataset provided by the City of Urbana Open Data Portal - https://data.urbanaillinois.us/Environment/Nuisance-Complaints/tsn9-95m3/about_data ")