Skip to content

Commit

Permalink
Enable passing subdiv to holidays
Browse files Browse the repository at this point in the history
- England now needs to be passed as country=UK, subdiv=England
  • Loading branch information
j0nnyr0berts committed Oct 7, 2022
1 parent 9aff502 commit e7bb452
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions timeserio/preprocessing/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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)


Expand Down

0 comments on commit e7bb452

Please sign in to comment.