Spaces:
Sleeping
Sleeping
Update index.py
Browse files
index.py
CHANGED
@@ -271,29 +271,29 @@ def update_output(selected_topic, selected_domain, start_date, end_date):
|
|
271 |
|
272 |
|
273 |
pie_container_1 = []
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
for media
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
|
298 |
return line_fig_1, bar_fig_1, line_fig_2, line_fig_3, line_fig_4, pie_container_1
|
299 |
else:
|
|
|
271 |
|
272 |
|
273 |
pie_container_1 = []
|
274 |
+
# Loop through each media category
|
275 |
+
row_content = []
|
276 |
+
for media in media_categories:
|
277 |
+
# Filter DataFrame for current media category
|
278 |
+
media_df = df[df['Veículos de notícias'] == media]
|
279 |
+
|
280 |
+
# Group by FinBERT_label and count occurrences
|
281 |
+
label_counts = media_df['FinBERT_label_transformed'].value_counts()
|
282 |
+
|
283 |
+
# Calculate percentage of each label
|
284 |
+
label_percentages = (label_counts / label_counts.sum()) * 100
|
285 |
+
|
286 |
+
# Plot pie chart
|
287 |
+
fig = px.pie(
|
288 |
+
values=label_percentages,
|
289 |
+
names=label_percentages.index,
|
290 |
+
title=f'Distribuição para {media}',
|
291 |
+
color_discrete_sequence=[label_colors[label] for label in label_percentages.index]
|
292 |
+
)
|
293 |
+
fig = dcc.Graph(figure=fig)
|
294 |
+
pie_chart = html.Div(fig,className='four columns')
|
295 |
+
row_content.append(pie_chart)
|
296 |
+
pie_container_1.append(html.Div(row_content, className='row'))
|
297 |
|
298 |
return line_fig_1, bar_fig_1, line_fig_2, line_fig_3, line_fig_4, pie_container_1
|
299 |
else:
|