Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
CHANGED
@@ -1,71 +1,33 @@
|
|
1 |
import streamlit as st
|
2 |
-
import altair as alt
|
3 |
import pandas as pd
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
.mark_point()
|
36 |
-
.encode(
|
37 |
-
alt.X("Year Constructed:Q", title="Year Constructed"),
|
38 |
-
alt.Y("Square Footage:Q", title="Square Footage"),
|
39 |
-
color=alt.condition(brush, color, alt.value("lightgray")),
|
40 |
-
size=alt.Size("Total Floors:Q", scale=alt.Scale(range=[50, 300]), title="Total Floors"),
|
41 |
-
tooltip=["Agency Name", "Location Name", "Square Footage", "Year Constructed"]
|
42 |
-
)
|
43 |
-
.properties(width=550, height=300, title="Building Size by Construction Year")
|
44 |
-
.add_params(brush)
|
45 |
-
.transform_filter(click)
|
46 |
-
)
|
47 |
-
|
48 |
-
# Bottom Panel: Bar Chart (Count of Building Status)
|
49 |
-
bar_chart = (
|
50 |
-
alt.Chart(data)
|
51 |
-
.mark_bar()
|
52 |
-
.encode(
|
53 |
-
x="count()",
|
54 |
-
y=alt.Y("Bldg Status:N", title="Building Status"),
|
55 |
-
color=alt.condition(click, color, alt.value("lightgray")),
|
56 |
-
)
|
57 |
-
.transform_filter(brush)
|
58 |
-
.properties(width=550, title="Building Status Distribution")
|
59 |
-
.add_params(click)
|
60 |
-
)
|
61 |
-
|
62 |
-
# Combined Chart
|
63 |
-
chart = alt.vconcat(scatter, bar_chart, title="Building Inventory Insights")
|
64 |
-
|
65 |
-
# Tabs for Themes
|
66 |
-
tab1, tab2 = st.tabs(["Streamlit Theme", "Altair Native Theme"])
|
67 |
-
|
68 |
-
with tab1:
|
69 |
-
st.altair_chart(chart, theme="streamlit", use_container_width=True)
|
70 |
-
with tab2:
|
71 |
-
st.altair_chart(chart, theme=None, use_container_width=True)
|
|
|
1 |
import streamlit as st
|
|
|
2 |
import pandas as pd
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
|
5 |
+
# Title of the app
|
6 |
+
st.title("Dataset Visualizer")
|
7 |
+
|
8 |
+
# File uploader for CSV files
|
9 |
+
url = "https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/building_inventory.csv"
|
10 |
+
|
11 |
+
data = pd.read_csv(url)
|
12 |
+
|
13 |
+
# Display the dataset
|
14 |
+
st.subheader("Dataset Preview")
|
15 |
+
st.write(data.head())
|
16 |
+
|
17 |
+
# Display basic statistics
|
18 |
+
st.subheader("Dataset Summary")
|
19 |
+
st.write(data.describe())
|
20 |
+
|
21 |
+
# Column selection for visualization
|
22 |
+
st.subheader("Data Visualization")
|
23 |
+
column = st.selectbox("Select a column for visualization", data.columns)
|
24 |
+
|
25 |
+
if column:
|
26 |
+
# Plot histogram for the selected column
|
27 |
+
st.write(f"Histogram for {column}")
|
28 |
+
fig, ax = plt.subplots()
|
29 |
+
data[column].hist(bins=20, ax=ax, color='skyblue', edgecolor='black')
|
30 |
+
ax.set_title(f"Histogram of {column}")
|
31 |
+
ax.set_xlabel(column)
|
32 |
+
ax.set_ylabel("Frequency")
|
33 |
+
st.pyplot(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|