Fix holidays NA handling

This commit is contained in:
Ben Letham 2021-03-03 16:06:25 -08:00
parent 2e9f831474
commit f123a1a7cc
2 changed files with 6 additions and 3 deletions

View file

@ -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)

View file

@ -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: