Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -255,10 +255,10 @@ with news_analysis:
|
|
| 255 |
print(events.shape, events.columns)
|
| 256 |
|
| 257 |
# Add a new column for positive values of column A
|
| 258 |
-
events['Positive_Impacts'] = events[events['Events_Impact']
|
| 259 |
|
| 260 |
# Add a new column for negative values of column A
|
| 261 |
-
events['Negative_Impacts'] = events[events['Events_Impact']
|
| 262 |
|
| 263 |
# Fill NaN values in the new columns with 0
|
| 264 |
events['Positive_Impacts'].fillna("", inplace=True)
|
|
@@ -275,7 +275,7 @@ with news_analysis:
|
|
| 275 |
)
|
| 276 |
# Create dummy traces for the legend
|
| 277 |
dummy_positive = go.Scatter(x=[None], y=[None], mode='lines', name='Positive Impacts',
|
| 278 |
-
marker=dict(color='
|
| 279 |
# visible='legendonly'
|
| 280 |
)
|
| 281 |
dummy_negative = go.Scatter(x=[None], y=[None], mode='lines', name='Negative Impacts',
|
|
@@ -366,11 +366,18 @@ with news_analysis:
|
|
| 366 |
news[col] = news[col].apply(convert_str_to_list)
|
| 367 |
# Extract only the date part
|
| 368 |
news['Date'] = news['Date'].dt.date
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
st.subheader("News Events")
|
| 370 |
# st.dataframe(news, hide_index=True)
|
| 371 |
# st.table(news)
|
| 372 |
dates = list(news['Date'].unique())
|
| 373 |
dates = np.sort(dates)
|
|
|
|
|
|
|
| 374 |
print(dates, len(dates))
|
| 375 |
num_dates = len(dates)
|
| 376 |
items_per_page = min(num_dates, 5)
|
|
|
|
| 255 |
print(events.shape, events.columns)
|
| 256 |
|
| 257 |
# Add a new column for positive values of column A
|
| 258 |
+
events['Positive_Impacts'] = events[events['Events_Impact'] >= 4.7]['Events_Impact']
|
| 259 |
|
| 260 |
# Add a new column for negative values of column A
|
| 261 |
+
events['Negative_Impacts'] = events[events['Events_Impact'] <= -4.7]['Events_Impact']
|
| 262 |
|
| 263 |
# Fill NaN values in the new columns with 0
|
| 264 |
events['Positive_Impacts'].fillna("", inplace=True)
|
|
|
|
| 275 |
)
|
| 276 |
# Create dummy traces for the legend
|
| 277 |
dummy_positive = go.Scatter(x=[None], y=[None], mode='lines', name='Positive Impacts',
|
| 278 |
+
marker=dict(color='green', size=15), showlegend=True,
|
| 279 |
# visible='legendonly'
|
| 280 |
)
|
| 281 |
dummy_negative = go.Scatter(x=[None], y=[None], mode='lines', name='Negative Impacts',
|
|
|
|
| 366 |
news[col] = news[col].apply(convert_str_to_list)
|
| 367 |
# Extract only the date part
|
| 368 |
news['Date'] = news['Date'].dt.date
|
| 369 |
+
# Sort DataFrame based on the 'Date' column in descending order
|
| 370 |
+
news = news.sort_values(by='Date', ascending=False)
|
| 371 |
+
|
| 372 |
+
# Reset index to reflect the new order
|
| 373 |
+
news.reset_index(drop=True, inplace=True)
|
| 374 |
st.subheader("News Events")
|
| 375 |
# st.dataframe(news, hide_index=True)
|
| 376 |
# st.table(news)
|
| 377 |
dates = list(news['Date'].unique())
|
| 378 |
dates = np.sort(dates)
|
| 379 |
+
# Reverse the array to have the latest date at index 0
|
| 380 |
+
dates = dates[::-1]
|
| 381 |
print(dates, len(dates))
|
| 382 |
num_dates = len(dates)
|
| 383 |
items_per_page = min(num_dates, 5)
|