Transformer
CountryHolidaysTransformer
Country Holidays Transformer.
This implementation wraps over holidays [1] by vacanza.
Based on the index of X, dates are extracted and passed to holidays. Then upon generating the holiday information for that day (or absence of it) based on passed country (and subdivision) information, a boolean series is prepared where True indicates the date being a holiday and False otherwise. fit is a no-op for this transformer.
Quickstart
python
from sktime.transformations.holiday.country_holidays import CountryHolidaysTransformer
estimator = CountryHolidaysTransformer(country, subdiv=None, years=None, expand=True, observed=True, categories=None, name=None)Tags
Capabilities
- Multivariate
- Missing values
- Unequal-length series
- Inverse transform: Not supported
- Removes missing values: Not supported
- Equalizes series length: Not supported
Properties
- Input typescitype:transform-input
- Series
- Output typescitype:transform-output
- Series
- Label typescitype:transform-labels
- None
- Fit is emptyfit_is_empty
- Yes
- Keeps the time indextransform-returns-same-time-index
- No
- Requires Xrequires_X
- Yes
- Requires yrequires_y
- No
- X and y need the same indexX-y-must-have-same-index
- No
Parameters(7)
- countrystr
An ISO 3166-1 Alpha-2 country code. [2]
- subdivstr, optional
The subdivision (e.g. state or province); not implemented for all countries (see documentation [3]). [2]
- yearsUnion[int, Iterable[int]], optional
- The year(s) to pre-calculate public holidays for at instantiation.
- expandbool, optional
- Whether the entire year is calculated when one date from that year is requested.
- observedbool, optional
- Whether to include the dates of when public holiday are observed (e.g. a holiday falling on a Sunday being observed the following Monday). False may not work for all countries.
- categoriesTuple[str], optional
- requested holiday categories.
- namestr, optional
- name of transformed series.
Examples
>>> from sktime.transformations.holiday import CountryHolidaysTransformer
>>>
>>> from sktime.datasets import load_airline
>>> y = load_airline ()
>>>
>>> y_t = CountryHolidaysTransformer ("US"). fit_transform (y)
>>> y_t. dtype dtype('bool')
>>> y_t. sum () 14
>>> y_t. name 'US_holidays'