From f768977493627aeb93daaa3f6e4b666c6a62106e Mon Sep 17 00:00:00 2001 From: Kalyan Date: Tue, 29 Sep 2020 09:07:15 -0700 Subject: [PATCH 1/3] fix: Disabling timezone of dataframe before passing Prophet While running forecasting with Druid. Prophet throws the following exception. This PR removes the timezone info. ValueError: Column ds has timezone specified, which is not supported. Remove timezone https://github.com/apache/incubator-superset/issues/11106 @villebro --- superset/utils/pandas_postprocessing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/superset/utils/pandas_postprocessing.py b/superset/utils/pandas_postprocessing.py index d73bee6a74f54..eb940fa2f3bd4 100644 --- a/superset/utils/pandas_postprocessing.py +++ b/superset/utils/pandas_postprocessing.py @@ -599,6 +599,7 @@ def _prophet_fit_and_predict( # pylint: disable=too-many-arguments weekly_seasonality=weekly_seasonality, daily_seasonality=daily_seasonality, ) + df['ds'] = df['ds'].dt.tz_convert(None) model.fit(df) future = model.make_future_dataframe(periods=periods, freq=freq) forecast = model.predict(future)[["ds", "yhat", "yhat_lower", "yhat_upper"]] From e4a3e78aecaf6208243aa5b21ca777809caf6277 Mon Sep 17 00:00:00 2001 From: Kalyan Date: Tue, 29 Sep 2020 10:34:09 -0700 Subject: [PATCH 2/3] Update pandas_postprocessing.py --- superset/utils/pandas_postprocessing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/utils/pandas_postprocessing.py b/superset/utils/pandas_postprocessing.py index eb940fa2f3bd4..4394c7ff68a98 100644 --- a/superset/utils/pandas_postprocessing.py +++ b/superset/utils/pandas_postprocessing.py @@ -599,7 +599,7 @@ def _prophet_fit_and_predict( # pylint: disable=too-many-arguments weekly_seasonality=weekly_seasonality, daily_seasonality=daily_seasonality, ) - df['ds'] = df['ds'].dt.tz_convert(None) + df["ds"] = df["ds"].dt.tz_convert(None) model.fit(df) future = model.make_future_dataframe(periods=periods, freq=freq) forecast = model.predict(future)[["ds", "yhat", "yhat_lower", "yhat_upper"]] From ac9d4169760797cea1dce4a2cedda2a44f441d47 Mon Sep 17 00:00:00 2001 From: Kalyan Date: Wed, 30 Sep 2020 06:49:47 -0700 Subject: [PATCH 3/3] Update superset/utils/pandas_postprocessing.py Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> --- superset/utils/pandas_postprocessing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/utils/pandas_postprocessing.py b/superset/utils/pandas_postprocessing.py index 4394c7ff68a98..47892e1c58046 100644 --- a/superset/utils/pandas_postprocessing.py +++ b/superset/utils/pandas_postprocessing.py @@ -599,7 +599,8 @@ def _prophet_fit_and_predict( # pylint: disable=too-many-arguments weekly_seasonality=weekly_seasonality, daily_seasonality=daily_seasonality, ) - df["ds"] = df["ds"].dt.tz_convert(None) + if df["ds"].dt.tz: + df["ds"] = df["ds"].dt.tz_convert(None) model.fit(df) future = model.make_future_dataframe(periods=periods, freq=freq) forecast = model.predict(future)[["ds", "yhat", "yhat_lower", "yhat_upper"]]