ralate2 commited on
Commit
ca6aa96
·
verified ·
1 Parent(s): 08c55a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -43,29 +43,31 @@ st.write("Column Data Types:", df.dtypes)
43
  # for col in df.select_dtypes(include='object').columns:
44
  # df[col] = df[col].astype('category')
45
 
46
- # Visualization 1: Bar chart of licenses by type
47
- st.subheader("Licenses by Type")
48
 
49
- category_counts = df['License Type'].value_counts().reset_index()
50
- category_counts.columns = ['License Type', 'Count']
51
 
52
- chart1 = alt.Chart(category_counts).mark_bar().encode(
 
53
  x=alt.X('License Type', sort='-y', title='License Type'),
54
  y=alt.Y('Count', title='Number of Licenses'),
55
- color=alt.Color('License Type', legend=None)
 
56
  ).properties(
57
- width=600,
58
  height=400,
59
- title="Number of Licenses by Type"
60
- )
 
61
  st.altair_chart(chart1)
62
 
63
  # Write-up for Visualization 1
64
  st.write("""
65
- **Licenses by Type**: This visualization highlights the distribution of licenses across different types.
66
- The bar chart was chosen for its simplicity in comparing counts across license types. I chose to sort types in descending order for clarity.
67
- Colors were selected to make each bar distinct, and axis labels were added for easy interpretation.
68
- If I had more time, I might add interactivity to allow users to filter by other variables.
69
  """)
70
 
71
  # Visualization 2: Line chart showing licenses issued over time
 
43
  # for col in df.select_dtypes(include='object').columns:
44
  # df[col] = df[col].astype('category')
45
 
46
+ # Visualization 1: Licenses by Type with License Status breakdown
47
+ st.subheader("Licenses by Type and Status")
48
 
49
+ # Group data by License Type and License Status
50
+ category_status_counts = df.groupby(['License Type', 'License Status']).size().reset_index(name='Count')
51
 
52
+ # Create a bar chart with color representing License Status
53
+ chart1 = alt.Chart(category_status_counts).mark_bar().encode(
54
  x=alt.X('License Type', sort='-y', title='License Type'),
55
  y=alt.Y('Count', title='Number of Licenses'),
56
+ color=alt.Color('License Status', legend=alt.Legend(title="License Status")),
57
+ tooltip=['License Type', 'License Status', 'Count']
58
  ).properties(
59
+ width=700,
60
  height=400,
61
+ title="Number of Licenses by Type and Status"
62
+ ).interactive()
63
+
64
  st.altair_chart(chart1)
65
 
66
  # Write-up for Visualization 1
67
  st.write("""
68
+ **Licenses by Type and Status**: This visualization shows the distribution of licenses across different types with further breakdown by license status.
69
+ The interactive chart allows users to view counts for each license status (e.g., active, inactive) within each license type.
70
+ This breakdown can help identify how license types vary not only in volume but also in the proportion of active versus inactive licenses.If I had more time, I might add interactivity to allow users to filter by other variables.
 
71
  """)
72
 
73
  # Visualization 2: Line chart showing licenses issued over time