bankholidays
Adds bank holidays for a given country.
Usage
Add a feature for a date, if it falls on a bank holiday, or if it’s a working day within before_span
and after_span
working days of one.
Exemple:
HOLIDAY ⇒ bank holiday (whichever one) (even if not a working day)
HOL_PLUS_2 ⇒ is a working day, and 2 working days after a bank holiday
HOL_MINUS_1 ⇒ is a working day, and 1 working day prior to a bank holiday
NO_HOLIDAY ⇒ not a working day nor a bank holiday, or no bank holidays within 2 working days of the date
This calculator can be used with the following method:
bankholidays
Examples:
Flag a bank holiday and the preceding three days to anticipate demand
Flag a bank holiday and the following day to create an alert based on the remaining stock after the bank holiday
Main Parameters
The bold options represent the default values when the parameters are optional.
input_columns list of columns used as input of the calculators: only one column containing the date.
output_columns list of columns added by the calculators : string value of the choice
global (true, false) Should this calculator be performed before data splitting during training for cross-validation
steps [optionnal] (training, prediction, postprocessing) List of steps in a pipeline where columns from this calculator are added to the data. Note that when the training option is listed, the calculator is actually added during preprocessing.
store_in_model [optionnal] (true, false) Please indicate whether the "calculated" columns by the calculator should be stored in the model or not to avoid recalculating them during prediction. This is only relevant if the calculated columns are added to both training and prediction. Without this parameter, the values will not be stored in the model. The following parameters only make sense if this parameter is set to true.
stored_columns [required if store_in_model is true] List indicating the columns to be stored among the output_columns.
stored_keys [required if store_in_model is true] List indicating the columns to use for identifying the correct values to join on the data for prediction among the stored values (logically, they are to be chosen from the input_columns).
Specific Parameters
country_code: A column name for the column containing the country code, or a country code. The country code must be a two-letter code, as described here: https://github.com/dr-prodigy/python-holidays (ISO 3166-1 alpha-2).
before_span The number of days to flag, before a bank holiday
after_span
The number of days to flag, after a bank holiday
Examples
Mark the French bank holidays, the two days preceding them, and the following day
Output:
2021-11-08
NO_HOLIDAY
2021-11-09
HOL_MINUS_2
2021-11-10
HOL_MINUS_1
2021-11-11
HOLIDAY
2021-11-12
HOL_PLUS_1
2021-11-13
NO_HOLIDAY
Last updated