Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,11 +54,20 @@ This bar chart illustrates the number of buildings in each county, highlighting
|
|
54 |
""")
|
55 |
|
56 |
# Visualization 2: Year-wise Construction of Buildings
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
yearly_construction.columns = ['Year Constructed', 'Building Count']
|
60 |
yearly_construction = yearly_construction.sort_values('Year Constructed')
|
61 |
|
|
|
|
|
62 |
year_chart = alt.Chart(yearly_construction).mark_line(point=True, color='orange').encode(
|
63 |
alt.X('Year Constructed:Q', title='Year Constructed'),
|
64 |
alt.Y('Building Count:Q', title='Number of Buildings'),
|
@@ -84,6 +93,7 @@ This line chart displays the number of buildings constructed each year, revealin
|
|
84 |
- Allow users to filter the data by building type or agency to explore specific trends.
|
85 |
""")
|
86 |
|
|
|
87 |
# Footer
|
88 |
st.markdown("""
|
89 |
---
|
|
|
54 |
""")
|
55 |
|
56 |
# Visualization 2: Year-wise Construction of Buildings
|
57 |
+
# Data Preprocessing for Year-wise Construction Visualization
|
58 |
+
# Convert 'Year Constructed' to numeric, handling errors
|
59 |
+
data['Year Constructed'] = pd.to_numeric(data['Year Constructed'], errors='coerce')
|
60 |
+
|
61 |
+
# Filter out rows where 'Year Constructed' is 0 or NaN
|
62 |
+
data_filtered = data[(data['Year Constructed'] > 0) & (~data['Year Constructed'].isna())]
|
63 |
+
|
64 |
+
# Group by 'Year Constructed' and count the number of buildings
|
65 |
+
yearly_construction = data_filtered['Year Constructed'].value_counts().reset_index()
|
66 |
yearly_construction.columns = ['Year Constructed', 'Building Count']
|
67 |
yearly_construction = yearly_construction.sort_values('Year Constructed')
|
68 |
|
69 |
+
# Visualization: Year-wise Construction of Buildings
|
70 |
+
st.header("2. Year-wise Construction of Buildings")
|
71 |
year_chart = alt.Chart(yearly_construction).mark_line(point=True, color='orange').encode(
|
72 |
alt.X('Year Constructed:Q', title='Year Constructed'),
|
73 |
alt.Y('Building Count:Q', title='Number of Buildings'),
|
|
|
93 |
- Allow users to filter the data by building type or agency to explore specific trends.
|
94 |
""")
|
95 |
|
96 |
+
|
97 |
# Footer
|
98 |
st.markdown("""
|
99 |
---
|