data.fetch_data.load_timeseries

data.fetch_data.load_timeseries(data_home=None)

Load the actual-load time series from interim/energy_load.csv. Reads the Actual Load column, converts the index to a UTC DatetimeIndex with hourly frequency, and fills any missing values with forward/backward fill.

Parameters

Name Type Description Default
data_home Optional[Union[str, Path]] Root data directory. If None, resolved via get_data_home(). None

Returns

Name Type Description
pd.Series pd.Series: Hourly actual-load series indexed by UTC timestamps.

Raises

Name Type Description
FileNotFoundError If interim/energy_load.csv does not exist.

Examples

>>> import os, tempfile, shutil
>>> import pandas as pd
>>> from spotforecast2_safe.data.fetch_data import (
...     load_timeseries, get_package_data_home,
... )
>>> tmp = tempfile.mkdtemp()
>>> os.environ["SPOTFORECAST2_DATA"] = tmp
>>> interim = os.path.join(tmp, "interim")
>>> os.makedirs(interim, exist_ok=True)
>>> demo = get_package_data_home() / "demo01.csv"
>>> df = pd.read_csv(demo)
>>> df = df.rename(columns={
...     "Time": "Time (UTC)",
...     "Actual": "Actual Load",
...     "Forecast": "Forecasted Load",
... })
>>> df.to_csv(os.path.join(interim, "energy_load.csv"), index=False)
>>> y = load_timeseries()
>>> isinstance(y, pd.Series)
True
>>> y.index.tz is not None
True
>>> shutil.rmtree(tmp)
>>> del os.environ["SPOTFORECAST2_DATA"]