From f123a1a7cc6ab51bd21f01e41738d97910a2b2b7 Mon Sep 17 00:00:00 2001 From: Ben Letham Date: Wed, 3 Mar 2021 16:06:25 -0800 Subject: [PATCH] Fix holidays NA handling --- R/R/prophet.R | 2 +- python/fbprophet/forecaster.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/R/R/prophet.R b/R/R/prophet.R index 6318d04..05d531f 100644 --- a/R/R/prophet.R +++ b/R/R/prophet.R @@ -169,7 +169,7 @@ validate_inputs <- function(m) { stop('Holidays dataframe must have ds field.') } m$holidays$ds <- as.Date(m$holidays$ds) - if (any(is.na(m$holidays))) { + if (any(is.na(m$holidays$ds)) | any(is.na(m$holidays$holiday))) { stop('Found NA in the holidays dataframe.') } has.lower <- exists('lower_window', where = m$holidays) diff --git a/python/fbprophet/forecaster.py b/python/fbprophet/forecaster.py index 038ff8c..18aec08 100644 --- a/python/fbprophet/forecaster.py +++ b/python/fbprophet/forecaster.py @@ -169,8 +169,11 @@ class Prophet(object): raise ValueError('holidays must be a DataFrame with "ds" and ' '"holiday" columns.') self.holidays['ds'] = pd.to_datetime(self.holidays['ds']) - if self.holidays.isnull().any().any(): - raise ValueError('Found a NaN in holidays dataframe') + if ( + self.holidays['ds'].isnull().any() + or self.holidays['holiday'].isnull().any() + ): + raise ValueError('Found a NaN in holidays dataframe.') has_lower = 'lower_window' in self.holidays has_upper = 'upper_window' in self.holidays if has_lower + has_upper == 1: