preprocessing.curate_data.get_start_end

preprocessing.curate_data.get_start_end(data, forecast_horizon, verbose=True)

Get start and end date strings for data and covariate ranges. Covariate range is extended by the forecast horizon.

Parameters

Name Type Description Default
data pd.DataFrame The dataset with a datetime index. required
forecast_horizon int The forecast horizon in hours. required
verbose bool Whether to print the determined date ranges. True

Returns

Name Type Description
tuple[str, str, str, str] tuple[str, str, str, str]: (data_start, data_end, covariate_start, covariate_end) Date strings in the format “YYYY-MM-DDTHH:MM” for data and covariate ranges.

Examples

import pandas as pd
from spotforecast2_safe.preprocessing.curate_data import get_start_end

date_rng = pd.date_range(start="2023-01-01", periods=48, freq="h", tz="UTC")
data = pd.DataFrame({"load": range(48)}, index=date_rng)
start, end, cov_start, cov_end = get_start_end(data, forecast_horizon=24, verbose=False)
print(f"data: {start}{end}")
print(f"covariates: {cov_start}{cov_end}")
assert start == "2023-01-01T00:00"
assert cov_end == "2023-01-03T23:00"
data: 2023-01-01T00:00 → 2023-01-02T23:00
covariates: 2023-01-01T00:00 → 2023-01-03T23:00