From 0bcc9d77a749adfdc5cb81a0ffce4882c02461c0 Mon Sep 17 00:00:00 2001 From: Kalyan Date: Wed, 30 Sep 2020 11:38:37 -0700 Subject: [PATCH] fix: Disabling timezone of dataframe before passing Prophet (#11107) * 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 * Update pandas_postprocessing.py * Update superset/utils/pandas_postprocessing.py Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> --- superset/utils/pandas_postprocessing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/superset/utils/pandas_postprocessing.py b/superset/utils/pandas_postprocessing.py index d73bee6a74..47892e1c58 100644 --- a/superset/utils/pandas_postprocessing.py +++ b/superset/utils/pandas_postprocessing.py @@ -599,6 +599,8 @@ def _prophet_fit_and_predict( # pylint: disable=too-many-arguments weekly_seasonality=weekly_seasonality, daily_seasonality=daily_seasonality, ) + 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"]]