Create a DataFrame with binary adjacency indicators for public holidays.
Returns three int columns, all disjoint from is_holiday:
is_brueckentag: 1 when day d is a working day (Mon–Fri AND not a public holiday) AND both d-1 and d+1 are non-working (public holiday or weekend, i.e. dayofweek >= 5). Saturday, Sunday, and public holidays are always 0.
is_before_holiday: 1 when d+1 is a public holiday AND d is not itself a public holiday.
is_after_holiday: 1 when d-1 is a public holiday AND d is not itself a public holiday.
A day may be flagged by more than one column simultaneously; for example, 2024-12-27 (Friday after Christmas/Boxing Day, before a long weekend) is both is_after_holiday and is_brueckentag.
Weekend membership is determined by dayofweek >= 5; the holidays library knows nothing about weekends, so this rule is applied explicitly.
Boundary rule: the first day of the requested range needs to know the holiday/weekend status of the day before start, and the last day needs the status of the day after end. Neighbour-day look-ups (d ± 1d) are performed directly against the holiday calendar object, which resolves any date on demand, so edge rows are never incorrectly zeroed.
import pandas as pdfrom spotforecast2_safe.calendar import create_holiday_adjacency_df# Unity Day 2024 (Thu 2024-10-03) is a public holiday in Germany.# 2024-10-04 (Fri) is therefore sandwiched between the holiday and the# weekend (Sat 2024-10-05, Sun 2024-10-06) → Brückentag.df = create_holiday_adjacency_df("2024-10-02", "2024-10-06", freq="D", country_code="DE", state="NW")print(df)assert df.loc["2024-10-04", "is_brueckentag"] ==1assert df.loc["2024-10-03", "is_brueckentag"] ==0# is_holiday, not Brückentagassert df.loc["2024-10-02", "is_before_holiday"] ==1# day before Unity Dayassert df.loc["2024-10-04", "is_after_holiday"] ==1# day after Unity Day