mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-07-30 20:18:11 +00:00
Better error messaging for required columns ds and y
This commit is contained in:
parent
44f82f6ea1
commit
7277e6c3b2
2 changed files with 11 additions and 0 deletions
|
|
@ -1043,6 +1043,12 @@ fit.prophet <- function(m, df, ...) {
|
|||
if (!is.null(m$history)) {
|
||||
stop("Prophet object can only be fit once. Instantiate a new object.")
|
||||
}
|
||||
if (!(exists('ds', where = df)) | !(exists('y', where = df))) {
|
||||
stop(paste(
|
||||
"Dataframe must have columns 'ds' and 'y' with the dates and values",
|
||||
"respectively."
|
||||
))
|
||||
}
|
||||
history <- df %>%
|
||||
dplyr::filter(!is.na(y))
|
||||
if (nrow(history) < 2) {
|
||||
|
|
|
|||
|
|
@ -927,6 +927,11 @@ class Prophet(object):
|
|||
if self.history is not None:
|
||||
raise Exception('Prophet object can only be fit once. '
|
||||
'Instantiate a new object.')
|
||||
if ('ds' not in df) or ('y' not in df):
|
||||
raise ValueError(
|
||||
"Dataframe must have columns 'ds' and 'y' with the dates and "
|
||||
"values respectively."
|
||||
)
|
||||
history = df[df['y'].notnull()].copy()
|
||||
if history.shape[0] < 2:
|
||||
raise ValueError('Dataframe has less than 2 non-NaN rows.')
|
||||
|
|
|
|||
Loading…
Reference in a new issue