Check for NAs in holiday dataframe

This commit is contained in:
Ben Letham 2021-03-03 15:43:49 -08:00
parent 29f14172f0
commit 2e9f831474
2 changed files with 5 additions and 0 deletions

View file

@ -169,6 +169,9 @@ 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))) {
stop('Found NA in the holidays dataframe.')
}
has.lower <- exists('lower_window', where = m$holidays)
has.upper <- exists('upper_window', where = m$holidays)
if (has.lower + has.upper == 1) {

View file

@ -169,6 +169,8 @@ 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')
has_lower = 'lower_window' in self.holidays
has_upper = 'upper_window' in self.holidays
if has_lower + has_upper == 1: