calendar.holiday.create_holiday_df

calendar.holiday.create_holiday_df(
    start,
    end,
    tz='UTC',
    freq='h',
    country_code='DE',
    state='NW',
)

Create a DataFrame with datetime index and a binary holiday indicator column.

Expands daily holidays to all timestamps in the desired frequency.

Parameters

Name Type Description Default
start str | pd.Timestamp Start date/datetime. required
end str | pd.Timestamp End date/datetime. required
tz str Timezone to use if not inferred from start/end. 'UTC'
freq str Frequency of the resulting DataFrame. 'h'
country_code str Country code for holidays (e.g. “DE”, “US”). 'DE'
state str State code for holidays (e.g. “NW”, “CA”). 'NW'

Returns

Name Type Description
pd.DataFrame pd.DataFrame: DataFrame with index covering [start, end] at freq, and an is_holiday column (1 if holiday, 0 otherwise).

Examples

from spotforecast2_safe.calendar import create_holiday_df
df = create_holiday_df("2023-12-24", "2023-12-26", freq="D")
print(df["is_holiday"].tolist())
[0, 1, 1]