Update app.py
Browse files
app.py
CHANGED
@@ -129,32 +129,31 @@ if 'key0' in st.session_state:
|
|
129 |
their respective labels in the table below.</div>""", unsafe_allow_html=True)
|
130 |
|
131 |
with col2:
|
132 |
-
|
133 |
-
|
134 |
|
135 |
# # Create a df that stores all the labels
|
136 |
-
|
137 |
|
138 |
-
#
|
139 |
-
|
140 |
|
141 |
-
#
|
142 |
-
|
143 |
|
144 |
-
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
# st.write(group_counts)
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
# # Merge the label counts with the df_label DataFrame
|
156 |
-
# df_labels = df_labels.merge(label_counts, on='Label', how='left')
|
157 |
|
|
|
|
|
|
|
|
|
158 |
# # Configure graph
|
159 |
# fig = px.pie(df_labels,
|
160 |
# names="Label",
|
|
|
129 |
their respective labels in the table below.</div>""", unsafe_allow_html=True)
|
130 |
|
131 |
with col2:
|
132 |
+
|
133 |
+
### Bar chart
|
134 |
|
135 |
# # Create a df that stores all the labels
|
136 |
+
df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
|
137 |
|
138 |
+
# Count how often each label appears in the "Vulnerability Labels" column
|
139 |
+
group_counts = {}
|
140 |
|
141 |
+
# Iterate through each sublist
|
142 |
+
for index, row in df_vul:
|
143 |
|
144 |
+
# Iterate through each group in the sublist
|
145 |
+
for sublist in row['Vulnerability Label']:
|
146 |
|
147 |
+
# Update the count in the dictionary
|
148 |
+
group_counts[sublist] = group_counts.get(sublist, 0) + 1
|
|
|
|
|
149 |
|
150 |
+
# Create a new dataframe from group_counts
|
151 |
+
df_label_count = pd.DataFrame(list(group_counts.items()), columns=['Label', 'Count'])
|
|
|
|
|
|
|
152 |
|
153 |
+
# Merge the label counts with the df_label DataFrame
|
154 |
+
df_label_count = df_labels.merge(df_label_counts, on='Label', how='left')
|
155 |
+
st.write("df_label_count")
|
156 |
+
|
157 |
# # Configure graph
|
158 |
# fig = px.pie(df_labels,
|
159 |
# names="Label",
|