Commit ·
979f8ec
1
Parent(s): 75594a8
Add licenses_fall2022.csv to data directory
Browse filesThis new CSV file contains details about various licenses, including license types, status, business information, and relevant dates. The data includes records from multiple professions such as cosmetologists, detectives, and dental professionals.
- app.py +110 -53
- data/licenses_fall2022.csv +0 -0
app.py
CHANGED
|
@@ -6,68 +6,125 @@
|
|
| 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 |
-
|
| 12 |
-
|
|
|
|
| 13 |
st.title('Streamlit App for IS445: ID29724')
|
| 14 |
|
| 15 |
st.text("The URL for this app is: https://huggingface.co/spaces/FantasticTony/is445_demo")
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 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 |
-
#
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
)
|
| 63 |
-
.add_params(click)
|
| 64 |
)
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# 5. use the URL from prior steps as intput into this simple browser
|
| 7 |
|
| 8 |
|
|
|
|
| 9 |
import altair as alt
|
| 10 |
+
import pandas as pd
|
| 11 |
+
import streamlit as st
|
| 12 |
+
|
| 13 |
st.title('Streamlit App for IS445: ID29724')
|
| 14 |
|
| 15 |
st.text("The URL for this app is: https://huggingface.co/spaces/FantasticTony/is445_demo")
|
| 16 |
|
| 17 |
+
licenses_data = pd.read_csv('data/licenses_fall2022.csv')
|
| 18 |
|
| 19 |
+
licenses_data_filtered = licenses_data[['License Type', 'License Status', 'LastModifiedDate']]
|
| 20 |
+
licenses_data_filtered['LastModifiedDate'] = pd.to_datetime(licenses_data_filtered['LastModifiedDate'], errors='coerce')
|
| 21 |
+
licenses_data_filtered.dropna(subset=['LastModifiedDate'], inplace=True)
|
| 22 |
+
|
| 23 |
+
# chart 1
|
| 24 |
+
license_type_counts = licenses_data_filtered['License Type'].value_counts().reset_index()
|
| 25 |
+
license_type_counts.columns = ['License Type', 'Count']
|
| 26 |
+
|
| 27 |
+
chart1 = alt.Chart(license_type_counts).mark_bar().encode(
|
| 28 |
+
x=alt.X('License Type:N', sort='-y', title='License Type'),
|
| 29 |
+
y=alt.Y('Count:Q', title='Number of Licenses'),
|
| 30 |
+
color=alt.Color('License Type:N', legend=None)
|
| 31 |
+
).properties(
|
| 32 |
+
title='Distribution of License Types',
|
| 33 |
+
width=600,
|
| 34 |
+
height=400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
+
# chart 2
|
| 38 |
+
licenses_data_filtered['Year'] = licenses_data_filtered['LastModifiedDate'].dt.year
|
| 39 |
+
license_status_counts = licenses_data_filtered.groupby(['Year', 'License Status']).size().reset_index(name='Count')
|
| 40 |
+
|
| 41 |
+
chart2 = alt.Chart(license_status_counts).mark_line().encode(
|
| 42 |
+
x=alt.X('Year:O', title='Year'),
|
| 43 |
+
y=alt.Y('Count:Q', title='Number of Licenses'),
|
| 44 |
+
color=alt.Color('License Status:N', title='License Status')
|
| 45 |
+
).properties(
|
| 46 |
+
title='License Status Over Time',
|
| 47 |
+
width=600,
|
| 48 |
+
height=400
|
|
|
|
|
|
|
| 49 |
)
|
| 50 |
|
| 51 |
+
# APP
|
| 52 |
+
st.title('Licenses Data Visualization')
|
| 53 |
+
|
| 54 |
+
st.write("## Visualization 1: Distribution of License Types")
|
| 55 |
+
st.altair_chart(chart1, use_container_width=True)
|
| 56 |
+
|
| 57 |
+
st.text("""
|
| 58 |
+
This bar chart shows the distribution of different license types in the dataset. I chose a bar chart
|
| 59 |
+
because it is effective for comparing categorical data like license types. The colors help to visually
|
| 60 |
+
differentiate each category. If I had more time, I would add interactive tooltips to display additional
|
| 61 |
+
information about each license type, such as the percentage of the total.
|
| 62 |
+
""")
|
| 63 |
+
|
| 64 |
+
st.write("## Visualization 2: License Status Over Time")
|
| 65 |
+
st.altair_chart(chart2, use_container_width=True)
|
| 66 |
|
| 67 |
+
st.text("""
|
| 68 |
+
This line chart shows the number of licenses by status (e.g., Active, Not Renewed) over time.
|
| 69 |
+
The chart helps to visualize trends in the renewal and activity status of licenses. I chose different colors
|
| 70 |
+
for each status to make it easy to distinguish between them. If I had more time, I would include an option
|
| 71 |
+
to filter by license type to see how specific types have changed over time.
|
| 72 |
+
""")
|
| 73 |
|
| 74 |
+
# source = data.seattle_weather()
|
| 75 |
+
#
|
| 76 |
+
# scale = alt.Scale(
|
| 77 |
+
# domain=["sun", "fog", "drizzle", "rain", "snow"],
|
| 78 |
+
# range=["#e7ba52", "#a7a7a7", "#aec7e8", "#1f77b4", "#9467bd"],
|
| 79 |
+
# )
|
| 80 |
+
# color = alt.Color("weather:N", scale=scale)
|
| 81 |
+
#
|
| 82 |
+
# # We create two selections:
|
| 83 |
+
# # - a brush that is active on the top panel
|
| 84 |
+
# # - a multi-click that is active on the bottom panel
|
| 85 |
+
# brush = alt.selection_interval(encodings=["x"])
|
| 86 |
+
# click = alt.selection_point(encodings=["color"])
|
| 87 |
+
#
|
| 88 |
+
# # Top panel is scatter plot of temperature vs time
|
| 89 |
+
# points = (
|
| 90 |
+
# alt.Chart()
|
| 91 |
+
# .mark_point()
|
| 92 |
+
# .encode(
|
| 93 |
+
# alt.X("monthdate(date):T", title="Date (Month Year)"),
|
| 94 |
+
# alt.Y(
|
| 95 |
+
# "temp_max:Q",
|
| 96 |
+
# title="Maximum Daily Temperature (C)",
|
| 97 |
+
# scale=alt.Scale(domain=[-5, 40]),
|
| 98 |
+
# ),
|
| 99 |
+
# color=alt.condition(brush, color, alt.value("lightgray")),
|
| 100 |
+
# size=alt.Size("precipitation:Q", scale=alt.Scale(range=[5, 200])),
|
| 101 |
+
# )
|
| 102 |
+
# .properties(width=550, height=300)
|
| 103 |
+
# .add_params(brush)
|
| 104 |
+
# .transform_filter(click)
|
| 105 |
+
# )
|
| 106 |
+
#
|
| 107 |
+
# # Bottom panel is a bar chart of weather type
|
| 108 |
+
# bars = (
|
| 109 |
+
# alt.Chart()
|
| 110 |
+
# .mark_bar()
|
| 111 |
+
# .encode(
|
| 112 |
+
# x="count()",
|
| 113 |
+
# y="weather:N",
|
| 114 |
+
# color=alt.condition(click, color, alt.value("lightgray")),
|
| 115 |
+
# )
|
| 116 |
+
# .transform_filter(brush)
|
| 117 |
+
# .properties(
|
| 118 |
+
# width=550,
|
| 119 |
+
# )
|
| 120 |
+
# .add_params(click)
|
| 121 |
+
# )
|
| 122 |
+
#
|
| 123 |
+
# chart = alt.vconcat(points, bars, data=source, title="Seattle Weather - 2006 to 2014")
|
| 124 |
+
#
|
| 125 |
+
# tab1, tab2 = st.tabs(["Streamlit theme (default)", "Altair native theme"])
|
| 126 |
+
#
|
| 127 |
+
# with tab1:
|
| 128 |
+
# st.altair_chart(chart, theme="streamlit", use_container_width=True)
|
| 129 |
+
# with tab2:
|
| 130 |
+
# st.altair_chart(chart, theme=None, use_container_width=True)
|
data/licenses_fall2022.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|