Skip to content

Readers

file reading support functions

read_yearly_load_projections(yearly_projections_p='resources/data/load/Province_Load_2020_2060.csv', conversion=1)

Prepare projections for model use

Parameters:

Name Type Description Default
yearly_projections_p PathLike

the data path. Defaults to "resources/data/load/Province_Load_2020_2060.csv".

'resources/data/load/Province_Load_2020_2060.csv'
conversion int

the conversion factor to MWh. Defaults to 1.

1

Returns:

Type Description
DataFrame

pd.DataFrame: the formatted data, in MWh

Source code in workflow/scripts/readers.py
def read_yearly_load_projections(
    yearly_projections_p: os.PathLike = "resources/data/load/Province_Load_2020_2060.csv",
    conversion=1,
) -> pd.DataFrame:
    """Prepare projections for model use

    Args:
        yearly_projections_p (os.PathLike, optional): the data path.
                Defaults to "resources/data/load/Province_Load_2020_2060.csv".
        conversion (int, optional): the conversion factor to MWh. Defaults to 1.

    Returns:
        pd.DataFrame: the formatted data, in MWh
    """
    yearly_proj = pd.read_csv(yearly_projections_p)
    yearly_proj.rename(columns={"Unnamed: 0": "province", "region": "province"}, inplace=True)
    if "province" not in yearly_proj.columns:
        raise ValueError(
            "The province (or region or unamed) column is missing in the yearly projections data"
            ". Index cannot be built"
        )
    yearly_proj.set_index("province", inplace=True)
    yearly_proj.rename(columns={c: int(c) for c in yearly_proj.columns}, inplace=True)

    return yearly_proj * conversion