thak123 commited on
Commit
835c130
·
verified ·
1 Parent(s): 4e18fb4

Update index.py

Browse files
Files changed (1) hide show
  1. index.py +23 -23
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
- for row in range(num_rows):
275
- row_content = []
276
- # Loop through each media category
277
- for media in media_categories:
278
- # Filter DataFrame for current media category
279
- media_df = df[df['Veículos de notícias'] == media]
280
-
281
- # Group by FinBERT_label and count occurrences
282
- label_counts = media_df['FinBERT_label_transformed'].value_counts()
283
-
284
- # Calculate percentage of each label
285
- label_percentages = (label_counts / label_counts.sum()) * 100
286
-
287
- # Plot pie chart
288
- fig = px.pie(
289
- values=label_percentages,
290
- names=label_percentages.index,
291
- title=f'Distribuição para {media}',
292
- color_discrete_sequence=[label_colors[label] for label in label_percentages.index]
293
- )
294
- pie_chart = html.Div(fig)
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:
 
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: