Skip to main content

Fetches holiday information from https://github.com/vacanza/holidays and applies reverse lagging (that is, future indicators) for time series training.

Project description

holiday-rlag

Fetches holiday information using the holidays library and applies reverse lagging (future indicators) for time series training.

Features

  • Fetches holidays for a given date range and country
  • Adds reverse lag markers for holidays using one column per holiday type
  • Flags for Easter, Christmas, and bank holidays

Installation

pip install holiday-rlag
# or, if using uv:
uv pip install .

Requirements

Usage

from holiday_rlag.laggedholidays import fetch_holidays
import datetime

date_start = datetime.date(2023, 1, 1)
date_end = datetime.date(2023, 12, 31)
holidays = fetch_holidays(date_start, date_end, country_code="DE", reverse_lag=7)

df = pd.DataFrame(holidays)

API

fetch_holidays(...)

Fetches holidays for a given date range and country, with optional reverse lagging.

Parameters:

  • date_start (datetime.date): Start date
  • date_end (datetime.date): End date
  • country_code (str): Country code (default: "DE")
  • reverse_lag (int): Number of days to look back for reverse lagging (default: 7)
  • col_is_easter, col_is_christmas, col_is_bank_holiday: Column names for flags
  • col_lag_prefix, col_lag_suffix: Prefix/suffix for lag marker columns

Returns:

  • list[dict]: List of dictionaries with holiday flags and lag marker values

Note: The result is not a complete date list. Fill all dates you need and apply fillna(0) if converting to a DataFrame.

For each holiday type, the reverse lag output uses a single column such as is_easter_in_next_days. If a matching holiday occurs within the configured lag window, the column contains the distance in days to the nearest upcoming holiday. Otherwise it stays empty and can be filled with 0 after conversion to a DataFrame.

Example Output

[
	{
		"date": "2023-04-07",
		"is_easter": 0,
		"is_christmas": 0,
		"is_bank_holiday": 1,
		"is_easter_in_next_days": 2,
		"is_bank_holiday_in_next_days": 2
	},
	...
]

License

MIT License. See LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

holiday_rlag-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

holiday_rlag-1.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file holiday_rlag-1.0.0.tar.gz.

File metadata

  • Download URL: holiday_rlag-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for holiday_rlag-1.0.0.tar.gz
Algorithm Hash digest
SHA256 757d0a8d912ff01b8035cd9688989b357e108b94ad8241bff79897f6e2a2ede9
MD5 cc26aa73bc18e8698d8ab2a27868adc9
BLAKE2b-256 3b8959b61a4382c0cff5849378339f54c4db940ba12792e2eec517a46e8f3216

See more details on using hashes here.

File details

Details for the file holiday_rlag-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: holiday_rlag-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for holiday_rlag-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d35ff17ab6d73d7d34d0a5c20bd2562f95218f5f1c4a3d240ddc81729b7153e
MD5 6543fa95045b7727a19ffc234a55b976
BLAKE2b-256 52a7eb4f9350a2d1b14cceabc217ec3d9f2d0ef962444a1dca0dc875a943d7ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page