utils.generate_holiday.create_holiday_df
utils.generate_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 | Union[str, pd.Timestamp] | Start date/datetime. | required |
| end | Union[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 a ‘holiday’ column (1 if holiday, 0 otherwise). |
Examples
>>> df = create_holiday_df("2023-12-24", "2023-12-26", freq="D")
>>> df["holiday"].tolist()
[0, 1, 1]