kchou6 commited on
Commit
860b3c4
1 Parent(s): 727776b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +65 -59
  2. requirements.txt +1 -2
app.py CHANGED
@@ -1,73 +1,79 @@
1
- # INSTRUCTIONS:
2
- # 1. Open a "Terminal" by: View --> Terminal OR just the "Terminal" through the hamburger menu
3
- # 2. run in terminal with: streamlit run app.py
4
- # 3. click the "Open in Browser" link that pops up OR click on "Ports" and copy the URL
5
- # 4. Open a Simple Browswer with View --> Command Palette --> Simple Browser: Show
6
- # 5. use the URL from prior steps as intput into this simple browser
7
 
8
-
9
- import streamlit as st
10
  import altair as alt
11
- from vega_datasets import data
12
-
13
- st.title('Streamlit App for IS445: ID13029')
14
 
15
- st.text("The URL for this app is: https://huggingface.co/spaces/kchou6/is445_demo")
 
 
16
 
17
- source = data.seattle_weather()
 
 
18
 
19
- scale = alt.Scale(
20
- domain=["sun", "fog", "drizzle", "rain", "snow"],
21
- range=["#e7ba52", "#a7a7a7", "#aec7e8", "#1f77b4", "#9467bd"],
 
 
 
 
 
 
 
 
 
 
 
22
  )
23
- color = alt.Color("weather:N", scale=scale)
24
 
25
- # We create two selections:
26
- # - a brush that is active on the top panel
27
- # - a multi-click that is active on the bottom panel
28
- brush = alt.selection_interval(encodings=["x"])
29
- click = alt.selection_point(encodings=["color"])
30
 
31
- # Top panel is scatter plot of temperature vs time
32
- points = (
33
- alt.Chart()
34
- .mark_point()
35
- .encode(
36
- alt.X("monthdate(date):T", title="Date (Month Year)"),
37
- alt.Y(
38
- "temp_max:Q",
39
- title="Maximum Daily Temperature (C)",
40
- scale=alt.Scale(domain=[-5, 40]),
41
- ),
42
- color=alt.condition(brush, color, alt.value("lightgray")),
43
- size=alt.Size("precipitation:Q", scale=alt.Scale(range=[5, 200])),
44
- )
45
- .properties(width=550, height=300)
46
- .add_params(brush)
47
- .transform_filter(click)
48
  )
49
 
50
- # Bottom panel is a bar chart of weather type
51
- bars = (
52
- alt.Chart()
53
- .mark_bar()
54
- .encode(
55
- x="count()",
56
- y="weather:N",
57
- color=alt.condition(click, color, alt.value("lightgray")),
58
- )
59
- .transform_filter(brush)
60
- .properties(
61
- width=550,
62
- )
63
- .add_params(click)
 
64
  )
65
 
66
- chart = alt.vconcat(points, bars, data=source, title="Seattle Weather - 2018 to 2027")
 
 
67
 
68
- tab1, tab2 = st.tabs(["Streamlit theme (default)", "Altair native theme"])
69
 
70
- with tab1:
71
- st.altair_chart(chart, theme="streamlit", use_container_width=True)
72
- with tab2:
73
- st.altair_chart(chart, theme=None, use_container_width=True)
 
 
 
 
 
 
 
 
 
1
+ # put streamlit code here as needed
 
 
 
 
 
2
 
3
+ import pandas as pd
 
4
  import altair as alt
5
+ import streamlit as st
 
 
6
 
7
+ url = "https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/building_inventory.csv"
8
+ data = pd.read_csv(url)
9
+ # print(data.head())
10
 
11
+ st.title("Building Inventory Visualization")
12
+ st.markdown("Displayed here are the data visuals from Building Inventory dataset.")
13
+ st.write(data.head())
14
 
15
+ # Visualization 1: Buildings by Usage Description
16
+ st.subheader("Buildings by Usage Description")
17
+ usage_data = data['Usage Description'].value_counts().reset_index()
18
+ usage_data.columns = ['Usage Description', 'Count']
19
+
20
+ chart5 = alt.Chart(usage_data).mark_bar().encode(
21
+ x=alt.X('Count:Q', title='Number of Buildings'),
22
+ y=alt.Y('Usage Description:N', sort='-x', title='Usage Description'),
23
+ color=alt.Color('Usage Description:N', legend=None),
24
+ tooltip=['Usage Description', 'Count']
25
+ ).properties(
26
+ width=600,
27
+ height=400,
28
+ title="Buildings by Usage Description"
29
  )
 
30
 
31
+ st.altair_chart(chart5, use_container_width=True)
 
 
 
 
32
 
33
+ # Write-up for Visualization 1
34
+ st.write("Buildings by Usage Description")
35
+ st.write(
36
+ "This bar chart represents the distribution of buildings based on their usage descriptions. "
37
+ "The x-axis displays the number of buildings, while the y-axis lists the various usage categories. "
38
+ "Each bar reflects the count of buildings in a specific usage type, with distinct colors to enhance readability and tooltips to show precise values."
39
+ )
40
+ st.write(
41
+ "I chose a bar chart because it effectively highlights the differences in building usage, making comparisons straightforward. "
42
+ "This visualization allows users to quickly identify the most common and least common usage types. "
43
+ "If I had more time, I would add advanced interactivity, such as a dropdown menu or filter, to explore specific usage categories or group similar types for deeper insights."
 
 
 
 
 
 
44
  )
45
 
46
+
47
+ # Visualization 2: Floor Count Distribution
48
+ st.subheader("Distribution of Number of Floors")
49
+ floor_count_data = data['Total Floors'].dropna().value_counts().reset_index()
50
+ floor_count_data.columns = ['Total Floors', 'Count']
51
+
52
+ chart4 = alt.Chart(floor_count_data).mark_bar().encode(
53
+ x=alt.X('Total Floors:O', title='Number of Floors'),
54
+ y=alt.Y('Count:Q', title='Number of Buildings'),
55
+ color=alt.Color('Total Floors:O', legend=None),
56
+ tooltip=['Total Floors', 'Count']
57
+ ).properties(
58
+ width=600,
59
+ height=400,
60
+ title="Distribution of Number of Floors in Buildings"
61
  )
62
 
63
+ st.altair_chart(chart4, use_container_width=True)
64
+
65
+
66
 
 
67
 
68
+ # Write-up for Visualization 2
69
+ st.write("Distribution of Number of Floors")
70
+ st.write(
71
+ "This bar chart visualizes the distribution of buildings based on the number of floors. "
72
+ "The x-axis represents the total number of floors, while the y-axis displays the count of buildings with that floor count. "
73
+ "Each bar is color-coded to improve visual appeal, and tooltips provide exact counts for added interactivity."
74
+ )
75
+ st.write(
76
+ "I chose a bar chart for this visualization because it effectively captures the distribution of floor counts and allows users to identify trends, "
77
+ "such as the most common floor counts. This visualization makes it easy to compare the data and spot unusual patterns. "
78
+ "If I had more time, I would incorporate filters or sliders to let users explore specific floor ranges or analyze the data further by other building attributes such as usage type or region."
79
+ )
requirements.txt CHANGED
@@ -1,3 +1,2 @@
1
- streamlit
2
  altair
3
- vega_datasets
 
1
+ pandas
2
  altair