From e7bb4523d9f5b39a504f3c43209a08f06186d90c Mon Sep 17 00:00:00 2001 From: Jonathan Roberts Date: Fri, 7 Oct 2022 12:10:01 +0100 Subject: [PATCH] Enable passing subdiv to holidays - England now needs to be passed as country=UK, subdiv=England --- timeserio/preprocessing/datetime.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/timeserio/preprocessing/datetime.py b/timeserio/preprocessing/datetime.py index 045f1cd..aacf5ca 100644 --- a/timeserio/preprocessing/datetime.py +++ b/timeserio/preprocessing/datetime.py @@ -3,7 +3,7 @@ import pandas as pd from sklearn.base import BaseEstimator, TransformerMixin from sklearn.utils.validation import check_is_fitted -from typing import List, Union +from typing import List, Union, Optional from .. import ini from .utils import _as_list_of_str, CallableMixin @@ -52,7 +52,7 @@ def get_fractional_year_from_series(series: pd.Series) -> pd.Series: def get_is_holiday_from_series( - series: pd.Series, country: str = "UnitedKingdom" + series: pd.Series, country: str = "UnitedKingdom", subdiv: Optional[str] = None, ) -> pd.Series: """Return 1 if day is a public holiday. @@ -61,7 +61,7 @@ def get_is_holiday_from_series( supported countries. """ years = series.dt.year.unique() - holiday_dates = holidays.CountryHoliday(country, years=years) + holiday_dates = holidays.country_holidays(country, subdiv=subdiv, years=years) return series.dt.date.isin(holiday_dates).astype(int)