Transformer
FinancialHolidaysTransformer
Financial Holidays Transformer.
Quickstart
python
from sktime.transformations.holiday.financial_holidays import FinancialHolidaysTransformer
estimator = FinancialHolidaysTransformer(market, years=None, expand=True, observed=True, name=None)Parameters(5)
- marketstr
An ISO 3166-1 Alpha-2 market code [2]; not implemented for all countries (see documentation [3]).
- 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.
- namestr, optional
- name of transformed series.
Examples
>>> from sktime.transformations.holiday import FinancialHolidaysTransformer
>>>
>>> import numpy
>>> data = numpy. random. default_rng (seed = 0). random (size = 365)
>>>
>>> import pandas
>>> index = pandas. date_range (start = "2023-01-01", end = "2023-12-31", freq = "D")
>>>
>>> y = pandas. Series (data, index = index, name = "random")
>>>
>>> y_t = FinancialHolidaysTransformer ("XNYS"). fit_transform (y)
>>> y_t. dtype dtype('bool')
>>> y_t. sum () 10
>>> y_t. name 'XNYS_holidays'References
- [1 ] https://github.com/vacanza/python-holidays [2 ] https://www.iso20022.org/market-identifier-codes [3 ] https://python-holidays.readthedocs.io/en/latest/#available-financial-markets