preprocessing.curate_data.curate_weather(weather_df, data, forecast_horizon)
Checks if the weather dataframe has the correct shape.
Parameters
weather_df
pd .DataFrame
DataFrame containing weather information.
required
data
pd .DataFrame
The main dataset.
required
forecast_horizon
int
The forecast horizon in hours.
required
Examples
import pandas as pd
from spotforecast2_safe.preprocessing.curate_data import curate_weather
FORECAST_HORIZON = 24
n_data = 48
data = pd.DataFrame(
{"load" : range (n_data)},
index= pd.date_range("2023-01-01" , periods= n_data, freq= "h" , tz= "UTC" ),
)
weather_df = pd.DataFrame(
{"temp" : range (n_data + FORECAST_HORIZON)},
index= pd.date_range(
"2023-01-01" , periods= n_data + FORECAST_HORIZON, freq= "h" , tz= "UTC"
),
)
curate_weather(weather_df, data, forecast_horizon= FORECAST_HORIZON)
assert weather_df.shape[0 ] == data.shape[0 ] + FORECAST_HORIZON
print ("weather_df shape is correct:" , weather_df.shape[0 ] == data.shape[0 ] + FORECAST_HORIZON)
weather_df shape is correct: True
Notes
If the weather dataframe does not have the expected number of rows, a diagnostic message describing the mismatch is logged via print and the function returns None without raising.