preprocessing.exog_builder.ExogBuilder
preprocessing.exog_builder.ExogBuilder(periods= None , country_code= None )
Builds a set of exogenous features for a given date range.
This builder combines temporal features (day of year, day of week, hour, etc.) with cyclical features encoded via RepeatingBasisFunctions and optional holiday indicators.
Attributes
periods
List [Period ]
List of periodic features to encode.
country_code
Optional [str ]
Country code for holiday lookups.
holidays_list
Optional [holidays.HolidayBase]
List of holidays for the specified country.
Examples
>>> import pandas as pd
>>> from spotforecast2_safe.data.data import Period
>>> from spotforecast2_safe.preprocessing.exog_builder import ExogBuilder
>>> periods = [Period(name= "hour" , n_periods= 24 , column= "hour" , input_range= (0 , 23 ))]
>>> builder = ExogBuilder(periods= periods, country_code= "DE" )
>>> start = pd.Timestamp("2025-01-01" , tz= "UTC" )
>>> end = pd.Timestamp("2025-01-02" , tz= "UTC" )
>>> exog = builder.build(start, end)
>>> exog.shape[1 ] > 0
True
Methods
build
Build the exogenous feature DataFrame for a date range.
build
preprocessing.exog_builder.ExogBuilder.build(start_date, end_date)
Build the exogenous feature DataFrame for a date range.
The generated DataFrame has an hourly frequency.
Parameters
start_date
pd .Timestamp
Start of the date range (inclusive).
required
end_date
pd .Timestamp
End of the date range (inclusive).
required
Returns
pd .DataFrame
pd.DataFrame: DataFrame containing exogenous features.
Examples
>>> import pandas as pd
>>> from spotforecast2_safe.data.data import Period
>>> from spotforecast2_safe.preprocessing.exog_builder import ExogBuilder
>>> periods = [Period(name= "hour" , n_periods= 24 , column= "hour" , input_range= (0 , 23 ))]
>>> builder = ExogBuilder(periods= periods, country_code= "DE" )
>>> start = pd.Timestamp("2025-01-01" , tz= "UTC" )
>>> end = pd.Timestamp("2025-01-02" , tz= "UTC" )
>>> exog = builder.build(start, end)
>>> exog.shape[1 ] > 0
True