Nazhar commited on
Commit
0ebe9ff
·
verified ·
1 Parent(s): a5b09d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -282,6 +282,7 @@ with news_analysis:
282
  cols = ['Raw_Headline', 'Bold_KW', 'Feature', 'Raw_News', 'Sources', 'Urls']
283
  for col in cols:
284
  events[col] = events[col].apply(convert_str_to_list)
 
285
  # Add a new column for positive values of column A
286
  events['Positive_Impacts'] = events[events['Events_Impact'] >= 4.7]['Events_Impact']
287
 
@@ -293,6 +294,12 @@ with news_analysis:
293
  events['Negative_Impacts'].fillna("", inplace=True)
294
  plot_sub_pos = events[events['Positive_Impacts']!='']
295
  plot_sub_neg = events[events['Negative_Impacts']!='']
 
 
 
 
 
 
296
  # Create the line trace for stock prices
297
  line_stock = go.Scatter(x=events['Date'], y=events['Price'], mode='lines', name='OGDCL Close Price',
298
  line=dict(dash='solid', color=cs.close_line_color, width=2),
@@ -322,13 +329,14 @@ with news_analysis:
322
  )
323
 
324
  # Add all traces to the figure
 
325
  figure = go.Figure(data=[line_stock], layout=layout)
326
  figure.add_scatter(x=plot_sub_pos['Date'], y=plot_sub_pos['Price'], mode='markers',
327
  marker=dict(symbol='triangle-up', size=10, color=cs.pos_impacts_color), name='Positive Impact',
328
- customdata=str(set(plot_sub_pos['Feature'])), hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>')
329
  figure.add_scatter(x=plot_sub_neg['Date'], y=plot_sub_neg['Price'], mode='markers',
330
  marker=dict(symbol='triangle-down', size=10, color=cs.neg_impacts_color), name='Negative Impact',
331
- customdata=str(set(plot_sub_neg['Feature'])), hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>',)
332
  figure.update_layout(
333
  title={
334
  'text': title,
@@ -719,10 +727,10 @@ with final_recs:
719
  figure = go.Figure(data=[line_stock], layout=layout)
720
  figure.add_scatter(x=plot_sub_pos['Date'], y=plot_sub_pos['Price'], mode='markers',
721
  marker=dict(symbol='triangle-up', size=10, color=cs.pos_impacts_color), name='Positive Impact',
722
- customdata=str(set(plot_sub_pos['Feature'])), hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>')
723
  figure.add_scatter(x=plot_sub_neg['Date'], y=plot_sub_neg['Price'], mode='markers',
724
  marker=dict(symbol='triangle-down', size=10, color=cs.neg_impacts_color), name='Negative Impact',
725
- customdata=str(set(plot_sub_neg['Feature'])), hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>',)
726
  figure.update_layout(
727
  title={
728
  'text': title,
 
282
  cols = ['Raw_Headline', 'Bold_KW', 'Feature', 'Raw_News', 'Sources', 'Urls']
283
  for col in cols:
284
  events[col] = events[col].apply(convert_str_to_list)
285
+
286
  # Add a new column for positive values of column A
287
  events['Positive_Impacts'] = events[events['Events_Impact'] >= 4.7]['Events_Impact']
288
 
 
294
  events['Negative_Impacts'].fillna("", inplace=True)
295
  plot_sub_pos = events[events['Positive_Impacts']!='']
296
  plot_sub_neg = events[events['Negative_Impacts']!='']
297
+ def get_set(list_value):
298
+ set_value = set(list_value)
299
+ return set_value
300
+
301
+ plot_sub_pos = plot_sub_pos['Feature'].apply(get_set)
302
+ plot_sub_neg = plot_sub_neg['Feature'].apply(get_set)
303
  # Create the line trace for stock prices
304
  line_stock = go.Scatter(x=events['Date'], y=events['Price'], mode='lines', name='OGDCL Close Price',
305
  line=dict(dash='solid', color=cs.close_line_color, width=2),
 
329
  )
330
 
331
  # Add all traces to the figure
332
+
333
  figure = go.Figure(data=[line_stock], layout=layout)
334
  figure.add_scatter(x=plot_sub_pos['Date'], y=plot_sub_pos['Price'], mode='markers',
335
  marker=dict(symbol='triangle-up', size=10, color=cs.pos_impacts_color), name='Positive Impact',
336
+ customdata=plot_sub_pos['Feature'], hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>')
337
  figure.add_scatter(x=plot_sub_neg['Date'], y=plot_sub_neg['Price'], mode='markers',
338
  marker=dict(symbol='triangle-down', size=10, color=cs.neg_impacts_color), name='Negative Impact',
339
+ customdata=plot_sub_neg['Feature'], hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>',)
340
  figure.update_layout(
341
  title={
342
  'text': title,
 
727
  figure = go.Figure(data=[line_stock], layout=layout)
728
  figure.add_scatter(x=plot_sub_pos['Date'], y=plot_sub_pos['Price'], mode='markers',
729
  marker=dict(symbol='triangle-up', size=10, color=cs.pos_impacts_color), name='Positive Impact',
730
+ customdata=plot_sub_pos['Feature'], hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>')
731
  figure.add_scatter(x=plot_sub_neg['Date'], y=plot_sub_neg['Price'], mode='markers',
732
  marker=dict(symbol='triangle-down', size=10, color=cs.neg_impacts_color), name='Negative Impact',
733
+ customdata=plot_sub_neg['Feature'], hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>',)
734
  figure.update_layout(
735
  title={
736
  'text': title,