From e877de6414684c7bb6ef638aae5092bcab10b23d Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Thu, 31 Mar 2022 18:06:24 +0000 Subject: [PATCH] use ffill in forecasting example --- notebook/automl_time_series_forecast.ipynb | 8 +++----- test/automl/test_forecast.py | 3 ++- website/docs/Examples/AutoML-Time series forecast.md | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/notebook/automl_time_series_forecast.ipynb b/notebook/automl_time_series_forecast.ipynb index 2909e3f3f1..898286b91b 100644 --- a/notebook/automl_time_series_forecast.ipynb +++ b/notebook/automl_time_series_forecast.ipynb @@ -152,13 +152,11 @@ "outputs": [], "source": [ "import statsmodels.api as sm\n", - "data = sm.datasets.co2.load_pandas()\n", - "data = data.data\n", + "data = sm.datasets.co2.load_pandas().data\n", "# data is given in weeks, but the task is to predict monthly, so use monthly averages instead\n", "data = data['co2'].resample('MS').mean()\n", - "data = data.fillna(data.bfill()) # makes sure there are no missing values\n", - "data = data.to_frame().reset_index()\n", - "# data = data.rename(columns={'index': 'ds', 'co2': 'y'})" + "data = data.bfill().ffill() # makes sure there are no missing values\n", + "data = data.to_frame().reset_index()" ] }, { diff --git a/test/automl/test_forecast.py b/test/automl/test_forecast.py index 1384127722..0f6f44e644 100644 --- a/test/automl/test_forecast.py +++ b/test/automl/test_forecast.py @@ -8,7 +8,8 @@ def test_forecast_automl(budget=5): data = sm.datasets.co2.load_pandas().data["co2"].resample("MS").mean() data = ( - data.fillna(data.bfill()) + data.bfill() + .ffill() .to_frame() .reset_index() .rename(columns={"index": "ds", "co2": "y"}) diff --git a/website/docs/Examples/AutoML-Time series forecast.md b/website/docs/Examples/AutoML-Time series forecast.md index 47519b6be2..72ff979e39 100644 --- a/website/docs/Examples/AutoML-Time series forecast.md +++ b/website/docs/Examples/AutoML-Time series forecast.md @@ -247,7 +247,7 @@ import statsmodels.api as sm data = sm.datasets.co2.load_pandas().data # data is given in weeks, but the task is to predict monthly, so use monthly averages instead data = data['co2'].resample('MS').mean() -data = data.fillna(data.bfill()) # makes sure there are no missing values +data = data.bfill().ffill() # makes sure there are no missing values data = data.to_frame().reset_index() num_samples = data.shape[0] time_horizon = 12