diff --git a/vessim/signal.py b/vessim/signal.py index 68e932c..cd39b4a 100644 --- a/vessim/signal.py +++ b/vessim/signal.py @@ -68,6 +68,13 @@ def __init__( fill_method: Literal["ffill", "bfill"] = "ffill", column: Optional[str] = None, ): + if isinstance(actual, pd.DataFrame) and forecast is not None: + if isinstance(forecast, pd.DataFrame): + if not actual.columns.equals(forecast.columns): + raise ValueError("Column names in actual and forecast do not match.") + else: + raise ValueError("Forecast has to be a DataFrame if actual is a DataFrame.") + self.default_column = column self._fill_method = fill_method # Unpack index of actual dataframe @@ -356,7 +363,8 @@ def _resample_to_frequency( else: # Actual value is used for interpolation times = np.insert(times, 0, start_time) - data = np.insert(data, 0, self.now(start_time, column)) + # https://github.com/dos-group/vessim/issues/234 + data = np.insert(data, 0, self.now(start_time, None if data.ndim == 1 else column)) if resample_method == "ffill": new_data = data[np.searchsorted(times, new_times, side="right") - 1] elif resample_method == "nearest":