Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,26 +61,43 @@ df['Original Issue Year'] = df['Original Issue Date'].dt.year
|
|
| 61 |
# st.altair_chart(chart1)
|
| 62 |
# else:
|
| 63 |
# st.write("No data available for the 'License Status' plot.")
|
| 64 |
-
# Visualization 1: Pie chart of licenses by Status with distinct colors and legend
|
| 65 |
-
st.subheader("Licenses by Status")
|
| 66 |
-
category_counts = df['License Status'].value_counts().reset_index()
|
| 67 |
-
category_counts.columns = ['License Status', 'Count']
|
| 68 |
-
|
| 69 |
-
if not category_counts.empty:
|
| 70 |
-
chart1 = alt.Chart(category_counts).mark_arc().encode(
|
| 71 |
-
theta=alt.Theta(field="Count", type="quantitative", title="Number of Licenses"),
|
| 72 |
-
color=alt.Color(field="License Status", type="nominal", legend=alt.Legend(title="License Status"),
|
| 73 |
-
scale=alt.Scale(scheme='category20')), # Distinct color scheme
|
| 74 |
-
tooltip=['License Status', 'Count']
|
| 75 |
-
).properties(
|
| 76 |
-
width=400,
|
| 77 |
-
height=400,
|
| 78 |
-
title="Licenses by Status"
|
| 79 |
-
)
|
| 80 |
-
st.altair_chart(chart1)
|
| 81 |
-
else:
|
| 82 |
-
st.write("No data available for the 'License Status' plot.")
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
# Write-up for Visualization 1
|
| 86 |
st.write("""
|
|
|
|
| 61 |
# st.altair_chart(chart1)
|
| 62 |
# else:
|
| 63 |
# st.write("No data available for the 'License Status' plot.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
# # Visualization 1: Pie chart of licenses by Status with distinct colors and legend
|
| 66 |
+
# st.subheader("Licenses by Status")
|
| 67 |
+
# category_counts = df['License Status'].value_counts().reset_index()
|
| 68 |
+
# category_counts.columns = ['License Status', 'Count']
|
| 69 |
+
|
| 70 |
+
# if not category_counts.empty:
|
| 71 |
+
# chart1 = alt.Chart(category_counts).mark_arc().encode(
|
| 72 |
+
# theta=alt.Theta(field="Count", type="quantitative", title="Number of Licenses"),
|
| 73 |
+
# color=alt.Color(field="License Status", type="nominal", legend=alt.Legend(title="License Status"),
|
| 74 |
+
# scale=alt.Scale(scheme='category20')), # Distinct color scheme
|
| 75 |
+
# tooltip=['License Status', 'Count']
|
| 76 |
+
# ).properties(
|
| 77 |
+
# width=400,
|
| 78 |
+
# height=400,
|
| 79 |
+
# title="Licenses by Status"
|
| 80 |
+
# )
|
| 81 |
+
# st.altair_chart(chart1)
|
| 82 |
+
# else:
|
| 83 |
+
# st.write("No data available for the 'License Status' plot.")
|
| 84 |
+
|
| 85 |
+
# Group data by License Status and State
|
| 86 |
+
state_status_counts = df.groupby(['State', 'License Status']).size().reset_index(name='Count')
|
| 87 |
+
|
| 88 |
+
# Visualization: Grouped Bar Chart
|
| 89 |
+
st.subheader("License Status by State")
|
| 90 |
+
chart_grouped = alt.Chart(state_status_counts).mark_bar().encode(
|
| 91 |
+
x=alt.X('State:N', title='State'),
|
| 92 |
+
y=alt.Y('Count:Q', title='Number of Licenses'),
|
| 93 |
+
color=alt.Color('License Status:N', title='License Status', scale=alt.Scale(scheme='category20')),
|
| 94 |
+
column=alt.Column('License Status:N', title='License Status')
|
| 95 |
+
).properties(
|
| 96 |
+
width=100,
|
| 97 |
+
height=400,
|
| 98 |
+
title="License Status by State"
|
| 99 |
+
)
|
| 100 |
+
st.altair_chart(chart_grouped)
|
| 101 |
|
| 102 |
# Write-up for Visualization 1
|
| 103 |
st.write("""
|