> For the complete documentation index, see [llms.txt](https://doc.verteego.com/verteego-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.verteego.com/verteego-doc/pipelines/forecasting-pipelines/calculators/temporal/bankholidays.md).

# bankholidays

Adds bank holidays for a given country.

## Usage

{% hint style="info" %}

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
  {% endhint %}

This calculator can be used with the following method:

<mark style="color:red;">**`bankholidays`**</mark>

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

{% hint style="success" %}
**The bold options** represent the default values when the parameters are optional.
{% endhint %}

* *<mark style="color:blue;">input\_columns</mark>* \
  list of columns used as input of the calculators: only one column containing the date.
* *<mark style="color:blue;">output\_columns</mark>* \
  list of columns added by the calculators : string value of the choice
* *<mark style="color:blue;">global</mark>* *(true, **false)*** \
  Should this calculator be performed before data splitting during training for cross-validation
* *<mark style="color:blue;">steps</mark>* \[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.
* *<mark style="color:blue;">store\_in\_model</mark>* \[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*.
* *<mark style="color:blue;">stored\_columns</mark>* \[required if *<mark style="color:blue;">store\_in\_model</mark> is true*] \
  List indicating the columns to be stored among the *<mark style="color:blue;">output\_columns</mark>*.
* *<mark style="color:blue;">stored\_keys</mark>* \[required if *<mark style="color:blue;">store\_in\_model</mark> 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 *<mark style="color:blue;">input\_columns</mark>*).

***

## Specific Parameters

* *<mark style="color:blue;">country\_code:</mark>* \
  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).
* *<mark style="color:blue;">before\_span</mark>*\
  The number of days to flag, before a bank holiday
* *<mark style="color:blue;">after\_span</mark>*&#x20;

  The number of days to flag, after a bank holiday

***

## Examples

1. Mark the French bank holidays, the two days preceding them, and the following day

```yaml
calculated_cols:
  bank_holidays:
      method: bank_holidays
      input_columns:
      - receipt_date
      output_columns:
      - holiday
      params:
          country_code: FR
          before_span: 2
          after_span: 1
```

**Output:**

| receipt\_date | holiday       |
| ------------- | ------------- |
| 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   |
