Changed so we are not looking at current_date as anchor but at past_date
Browse files
app.py
CHANGED
|
@@ -432,10 +432,17 @@ def run_app():
|
|
| 432 |
# Create a Table that displays the forecast of each dataframe total for two months before date and two months after
|
| 433 |
# Filter dates for two months before and after the current date
|
| 434 |
# Define date ranges
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
# Assuming df is the DataFrame containing the date index and the 'Total' column
|
| 441 |
|
|
@@ -479,7 +486,7 @@ def run_app():
|
|
| 479 |
df_photo_date_filtered = monthly_average_photo_date[
|
| 480 |
(monthly_average_photo_date.index == two_months_before) |
|
| 481 |
(monthly_average_photo_date.index == one_month_before) |
|
| 482 |
-
(monthly_average_photo_date.index ==
|
| 483 |
(monthly_average_photo_date.index == one_month_after) |
|
| 484 |
(monthly_average_photo_date.index == two_months_after)
|
| 485 |
]
|
|
@@ -501,7 +508,7 @@ def run_app():
|
|
| 501 |
|
| 502 |
# Create a DataFrame for display
|
| 503 |
data_avg_expected_normal = {
|
| 504 |
-
'Dates': [two_months_before, one_month_before,
|
| 505 |
f"Forecast update {current_date_str}": current_forecast_update,
|
| 506 |
f"Forecast update {past_date_str}": past_forecast_update,
|
| 507 |
'Delta': delta
|
|
|
|
| 432 |
# Create a Table that displays the forecast of each dataframe total for two months before date and two months after
|
| 433 |
# Filter dates for two months before and after the current date
|
| 434 |
# Define date ranges
|
| 435 |
+
|
| 436 |
+
## I am under the impression that I will need to use past_date for the offset
|
| 437 |
+
# two_months_before = (current_date - pd.DateOffset(months=2)).strftime('%Y-%m')
|
| 438 |
+
# one_month_before = (current_date - pd.DateOffset(months=1)).strftime('%Y-%m')
|
| 439 |
+
# one_month_after = (current_date + pd.DateOffset(months=1)).strftime('%Y-%m')
|
| 440 |
+
# two_months_after = (current_date + pd.DateOffset(months=2)).strftime('%Y-%m')
|
| 441 |
+
|
| 442 |
+
two_months_before = (past_date - pd.DateOffset(months=2)).strftime('%Y-%m')
|
| 443 |
+
one_month_before = (past_date - pd.DateOffset(months=1)).strftime('%Y-%m')
|
| 444 |
+
one_month_after = (past_date + pd.DateOffset(months=1)).strftime('%Y-%m')
|
| 445 |
+
two_months_after = (past_date + pd.DateOffset(months=2)).strftime('%Y-%m')
|
| 446 |
|
| 447 |
# Assuming df is the DataFrame containing the date index and the 'Total' column
|
| 448 |
|
|
|
|
| 486 |
df_photo_date_filtered = monthly_average_photo_date[
|
| 487 |
(monthly_average_photo_date.index == two_months_before) |
|
| 488 |
(monthly_average_photo_date.index == one_month_before) |
|
| 489 |
+
(monthly_average_photo_date.index == past_date.strftime('%Y-%m')) |
|
| 490 |
(monthly_average_photo_date.index == one_month_after) |
|
| 491 |
(monthly_average_photo_date.index == two_months_after)
|
| 492 |
]
|
|
|
|
| 508 |
|
| 509 |
# Create a DataFrame for display
|
| 510 |
data_avg_expected_normal = {
|
| 511 |
+
'Dates': [two_months_before, one_month_before, past_date.strftime('%Y-%m'), one_month_after, two_months_after],
|
| 512 |
f"Forecast update {current_date_str}": current_forecast_update,
|
| 513 |
f"Forecast update {past_date_str}": past_forecast_update,
|
| 514 |
'Delta': delta
|