thak123 commited on
Commit
1162dad
·
verified ·
1 Parent(s): 5b0824e

Update index.py

Browse files
Files changed (1) hide show
  1. index.py +22 -26
index.py CHANGED
@@ -195,6 +195,7 @@ app.layout = dbc.Container([
195
  Output('pie-container-1', 'figure'),
196
  Output('line-graph-2', 'figure'),
197
  Output('pie-container-2', 'figure'),
 
198
  Input("topic-selector", "value"),
199
  Input("domain-selector", "value"),
200
  Input('date-range', 'start_date'),
@@ -323,8 +324,16 @@ def update_output(selected_topic, selected_domain, start_date, end_date):
323
  )
324
  # pie_chart_2 = dcc.Graph(figure=fig)
325
  # pie_chart_2 = html.Div(fig,className='four columns')
326
-
327
- return line_fig_1, bar_fig_1, pie_chart_1, line_fig_2, pie_chart_2
 
 
 
 
 
 
 
 
328
  else:
329
  return {'data': []},{'data': []} ,{'data': []} ,{'data': []} , {'data': []}
330
 
@@ -350,30 +359,17 @@ def update_output(selected_topic, selected_domain, start_date, end_date):
350
  # dff = df[df.country==value]
351
  # return px.line(dff, x='year', y='pop')
352
 
353
- # Define callback function for updating the headlines table
354
- @app.callback(
355
- Output('headlines-table', 'data'),
356
- Input("topic-selector", "value"),
357
- Input("domain-selector", "value"),
358
- Input('date-range', 'start_date'),
359
- Input('date-range', 'end_date')
360
- )
361
- def update_headlines_table(selected_topic, selected_domain, start_date, end_date):
362
- # Filtering data...
363
- df_filtered = df[(df['Topic'] == selected_topic) &
364
- (df['domain_folder_name'] == selected_domain) &
365
- (df['date'] >= start_date) &
366
- (df['date'] <= end_date)]
367
-
368
- # Convert FinBERT_label to categorical for better sorting
369
- df_filtered['FinBERT_label'] = pd.Categorical(df_filtered['FinBERT_label'],
370
- categories=['positive', 'neutral', 'negative'],
371
- ordered=True)
372
-
373
- # Sort DataFrame by sentiment label and date
374
- df_filtered = df_filtered.sort_values(by=['FinBERT_label', 'date'])
375
-
376
- return df_filtered.to_dict('records')
377
 
378
  if __name__ == '__main__':
379
  app.run_server(debug=True)
 
195
  Output('pie-container-1', 'figure'),
196
  Output('line-graph-2', 'figure'),
197
  Output('pie-container-2', 'figure'),
198
+ Output('headlines-table', 'data'),
199
  Input("topic-selector", "value"),
200
  Input("domain-selector", "value"),
201
  Input('date-range', 'start_date'),
 
324
  )
325
  # pie_chart_2 = dcc.Graph(figure=fig)
326
  # pie_chart_2 = html.Div(fig,className='four columns')
327
+
328
+ # Convert FinBERT_label to categorical for better sorting
329
+ df_filtered['FinBERT_label'] = pd.Categorical(df_filtered['FinBERT_label'],
330
+ categories=['positive', 'neutral', 'negative'],
331
+ ordered=True)
332
+
333
+ # Sort DataFrame by sentiment label and date
334
+ df_filtered = df_filtered.sort_values(by=['FinBERT_label', 'date'])
335
+
336
+ return line_fig_1, bar_fig_1, pie_chart_1, line_fig_2, pie_chart_2, df_filtered.to_dict('records')
337
  else:
338
  return {'data': []},{'data': []} ,{'data': []} ,{'data': []} , {'data': []}
339
 
 
359
  # dff = df[df.country==value]
360
  # return px.line(dff, x='year', y='pop')
361
 
362
+ # # Define callback function for updating the headlines table
363
+ # @app.callback(
364
+ # Output('headlines-table', 'data'),
365
+ # Input("topic-selector", "value"),
366
+ # Input("domain-selector", "value"),
367
+ # Input('date-range', 'start_date'),
368
+ # Input('date-range', 'end_date')
369
+ # )
370
+ # def update_headlines_table(selected_topic, selected_domain, start_date, end_date):
371
+ # # Filtering data...
372
+
 
 
 
 
 
 
 
 
 
 
 
 
 
373
 
374
  if __name__ == '__main__':
375
  app.run_server(debug=True)