leavoigt commited on
Commit
857a9de
1 Parent(s): b661f99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
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
- st.write("")
133
- # ### Pie 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 group in row['Vulnerability Label']:
146
 
147
- # # Update the count in the dictionary
148
- # group_counts[group] = group_counts.get(group, 0) + 1
149
-
150
- # st.write(group_counts)
151
 
152
- # label_counts = df_vul['Vulnerability Label'].value_counts().reset_index()
153
- # label_counts.columns = ['Label', 'Count']
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",