Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,13 +30,12 @@ county_count.columns = ['County', 'Building Count']
|
|
30 |
|
31 |
county_chart = alt.Chart(county_count).mark_bar(color='teal').encode(
|
32 |
alt.X('Building Count:Q', title='Number of Buildings'),
|
33 |
-
alt.Y('County:N', sort='-x', title='County')
|
34 |
-
tooltip=['County', 'Building Count']
|
35 |
).properties(
|
36 |
width=700,
|
37 |
height=400,
|
38 |
title='Number of Buildings per County'
|
39 |
-
)
|
40 |
|
41 |
st.altair_chart(county_chart, use_container_width=True)
|
42 |
|
@@ -47,17 +46,13 @@ This bar chart illustrates the number of buildings in each county, highlighting
|
|
47 |
- A horizontal bar chart is used to accommodate long county names and facilitate easy comparison.
|
48 |
- Counties are sorted in descending order based on building count to emphasize those with the most buildings.
|
49 |
- The teal color provides a calm and professional appearance.
|
50 |
-
- Interactive tooltips offer precise counts upon hovering.
|
51 |
- **Potential Improvements**:
|
52 |
- Incorporate filters to allow users to focus on specific regions or agencies.
|
53 |
- Add a map visualization to provide spatial context to the data.
|
54 |
""")
|
55 |
|
56 |
# Visualization 2: Year-wise Construction of Buildings
|
57 |
-
|
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 |
|
@@ -66,17 +61,14 @@ yearly_construction = data_filtered['Year Constructed'].value_counts().reset_ind
|
|
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')
|
74 |
-
tooltip=['Year Constructed', 'Building Count']
|
75 |
).properties(
|
76 |
width=700,
|
77 |
height=400,
|
78 |
title='Number of Buildings Constructed Over Time'
|
79 |
-
)
|
80 |
|
81 |
st.altair_chart(year_chart, use_container_width=True)
|
82 |
|
@@ -87,13 +79,11 @@ This line chart displays the number of buildings constructed each year, revealin
|
|
87 |
- A line chart effectively shows changes over time and highlights trends.
|
88 |
- Data points are marked to emphasize individual years.
|
89 |
- The orange color draws attention to the trend line.
|
90 |
-
- Interactive tooltips provide exact counts for each year.
|
91 |
- **Potential Improvements**:
|
92 |
- Implement a rolling average to smooth out year-to-year fluctuations.
|
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 |
---
|
|
|
30 |
|
31 |
county_chart = alt.Chart(county_count).mark_bar(color='teal').encode(
|
32 |
alt.X('Building Count:Q', title='Number of Buildings'),
|
33 |
+
alt.Y('County:N', sort='-x', title='County')
|
|
|
34 |
).properties(
|
35 |
width=700,
|
36 |
height=400,
|
37 |
title='Number of Buildings per County'
|
38 |
+
)
|
39 |
|
40 |
st.altair_chart(county_chart, use_container_width=True)
|
41 |
|
|
|
46 |
- A horizontal bar chart is used to accommodate long county names and facilitate easy comparison.
|
47 |
- Counties are sorted in descending order based on building count to emphasize those with the most buildings.
|
48 |
- The teal color provides a calm and professional appearance.
|
|
|
49 |
- **Potential Improvements**:
|
50 |
- Incorporate filters to allow users to focus on specific regions or agencies.
|
51 |
- Add a map visualization to provide spatial context to the data.
|
52 |
""")
|
53 |
|
54 |
# Visualization 2: Year-wise Construction of Buildings
|
55 |
+
st.header("2. Year-wise Construction of Buildings")
|
|
|
|
|
|
|
56 |
# Filter out rows where 'Year Constructed' is 0 or NaN
|
57 |
data_filtered = data[(data['Year Constructed'] > 0) & (~data['Year Constructed'].isna())]
|
58 |
|
|
|
61 |
yearly_construction.columns = ['Year Constructed', 'Building Count']
|
62 |
yearly_construction = yearly_construction.sort_values('Year Constructed')
|
63 |
|
|
|
|
|
64 |
year_chart = alt.Chart(yearly_construction).mark_line(point=True, color='orange').encode(
|
65 |
alt.X('Year Constructed:Q', title='Year Constructed'),
|
66 |
+
alt.Y('Building Count:Q', title='Number of Buildings')
|
|
|
67 |
).properties(
|
68 |
width=700,
|
69 |
height=400,
|
70 |
title='Number of Buildings Constructed Over Time'
|
71 |
+
)
|
72 |
|
73 |
st.altair_chart(year_chart, use_container_width=True)
|
74 |
|
|
|
79 |
- A line chart effectively shows changes over time and highlights trends.
|
80 |
- Data points are marked to emphasize individual years.
|
81 |
- The orange color draws attention to the trend line.
|
|
|
82 |
- **Potential Improvements**:
|
83 |
- Implement a rolling average to smooth out year-to-year fluctuations.
|
84 |
- Allow users to filter the data by building type or agency to explore specific trends.
|
85 |
""")
|
86 |
|
|
|
87 |
# Footer
|
88 |
st.markdown("""
|
89 |
---
|