Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,30 +23,45 @@ data = load_data()
|
|
23 |
data['Year Acquired'] = pd.to_numeric(data['Year Acquired'], errors='coerce')
|
24 |
data['Square Footage'] = pd.to_numeric(data['Square Footage'], errors='coerce')
|
25 |
|
26 |
-
#
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
).properties(
|
32 |
width=700,
|
33 |
height=400,
|
34 |
-
title="
|
35 |
-
)
|
36 |
-
|
|
|
37 |
|
38 |
st.markdown("""
|
39 |
### Explanation
|
40 |
-
This
|
41 |
- **Design Choices**:
|
42 |
-
- A
|
43 |
-
-
|
44 |
-
-
|
|
|
45 |
- **Potential Improvements**:
|
46 |
-
-
|
47 |
-
-
|
48 |
""")
|
49 |
|
|
|
50 |
# Visualization 2: Square Footage by Usage Description
|
51 |
st.header("Square Footage by Usage Description")
|
52 |
usage_chart = alt.Chart(data).mark_boxplot().encode(
|
|
|
23 |
data['Year Acquired'] = pd.to_numeric(data['Year Acquired'], errors='coerce')
|
24 |
data['Square Footage'] = pd.to_numeric(data['Square Footage'], errors='coerce')
|
25 |
|
26 |
+
# Data Preprocessing for New Visualization
|
27 |
+
# Convert 'Year Acquired' and 'Square Footage' to numeric, handling errors
|
28 |
+
data['Year Acquired'] = pd.to_numeric(data['Year Acquired'], errors='coerce')
|
29 |
+
data['Square Footage'] = pd.to_numeric(data['Square Footage'], errors='coerce')
|
30 |
+
|
31 |
+
# Remove rows with missing or invalid data in 'Year Acquired' or 'Square Footage'
|
32 |
+
data_clean = data.dropna(subset=['Year Acquired', 'Square Footage'])
|
33 |
+
|
34 |
+
# Group by 'Year Acquired' and sum 'Square Footage'
|
35 |
+
yearly_square_footage = data_clean.groupby('Year Acquired')['Square Footage'].sum().reset_index()
|
36 |
+
|
37 |
+
# Visualization: Total Square Footage Acquired Over Time
|
38 |
+
st.header("Total Square Footage Acquired Over Time")
|
39 |
+
line_chart = alt.Chart(yearly_square_footage).mark_line(point=True, color='seagreen').encode(
|
40 |
+
alt.X('Year Acquired:Q', title="Year Acquired"),
|
41 |
+
alt.Y('Square Footage:Q', title="Total Square Footage"),
|
42 |
+
tooltip=['Year Acquired', 'Square Footage']
|
43 |
).properties(
|
44 |
width=700,
|
45 |
height=400,
|
46 |
+
title="Total Square Footage Acquired Over Time"
|
47 |
+
).interactive()
|
48 |
+
|
49 |
+
st.altair_chart(line_chart, use_container_width=True)
|
50 |
|
51 |
st.markdown("""
|
52 |
### Explanation
|
53 |
+
This line chart illustrates the total square footage of buildings acquired each year, highlighting trends in acquisition sizes over time.
|
54 |
- **Design Choices**:
|
55 |
+
- A line chart was selected to effectively display changes over time.
|
56 |
+
- Data points are marked to emphasize individual years.
|
57 |
+
- The seagreen color provides a calm and clear visual.
|
58 |
+
- Interactive tooltips offer precise values upon hovering.
|
59 |
- **Potential Improvements**:
|
60 |
+
- Incorporating filters to view trends for specific agencies or locations.
|
61 |
+
- Adding a moving average line to smooth out year-to-year fluctuations.
|
62 |
""")
|
63 |
|
64 |
+
|
65 |
# Visualization 2: Square Footage by Usage Description
|
66 |
st.header("Square Footage by Usage Description")
|
67 |
usage_chart = alt.Chart(data).mark_boxplot().encode(
|