Holidays class

Definition

Methods and classes used to get public holidays infomation.

Holidays()
Inheritance
builtins.object
Holidays

Methods

adding_holidayname_by_window(_country: str, _countryCode: str, _name: str, window: int, window_type: str, curDate: datetime.datetime, data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame

Generate holiday window name.

adding_holidayname_by_window_row_by_row(data: pandas.core.frame.DataFrame, target_data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame

Generate holiday window names row by row.

get_holidays_dates(country_code: typing.Union[str, NoneType] = None, country_or_region: typing.Union[str, NoneType] = None) -> typing.Union[typing.Dict[datetime.datetime, NoneType], NoneType]

Get a Dict with Key of the dates of holidays.

get_holidays_in_range(start_date: datetime.date, end_date: datetime.date, country_code: str = 'US') -> pandas.core.frame.DataFrame

Get a list of holiday infomation base on the given date range.

get_holidays_in_range_by_country_or_region(start_date: datetime.date, end_date: datetime.date, country_or_region: str = 'United States') -> pandas.core.frame.DataFrame

Get a list of holiday infomation base on the given date range.

get_window_by_effect_gap(effect: str, gap: int) -> int

Generate holiday window number.

is_holiday(target_date: datetime.date, country_code: str = 'US') -> bool

Detect a date is a holiday or not.

is_holiday_by_country_or_region(target_date: datetime.date, country_or_region: str = 'United States') -> bool

Detect a date is a holiday or not.

update_holidays_by_adding_window() -> None

Generate the holidays csv with window into name.

adding_holidayname_by_window(_country: str, _countryCode: str, _name: str, window: int, window_type: str, curDate: datetime.datetime, data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame

Generate holiday window name.

adding_holidayname_by_window(_country: str, _countryCode: str, _name: str, window: int, window_type: str, curDate: datetime.datetime, data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame

Parameters

_country

country/region of current data.

_countryCode

countryCode of current data.

_name

holiday name which needs be processed.

window

window of current holiday.

window_type

lower window or upper window.

curDate

date of the holiday.

data

holiday data which needs be processed.

Returns

The dataframe with holidayname base on the window added row by row.

adding_holidayname_by_window_row_by_row(data: pandas.core.frame.DataFrame, target_data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame

Generate holiday window names row by row.

adding_holidayname_by_window_row_by_row(data: pandas.core.frame.DataFrame, target_data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame

Parameters

data

holiday data which needs be iterated.

target_data

holiday data which needs be processed.

Returns

The dataframe with holidayname base on the window added row by row.

get_holidays_dates(country_code: typing.Union[str, NoneType] = None, country_or_region: typing.Union[str, NoneType] = None) -> typing.Union[typing.Dict[datetime.datetime, NoneType], NoneType]

Get a Dict with Key of the dates of holidays.

get_holidays_dates(country_code: typing.Union[str, NoneType] = None, country_or_region: typing.Union[str, NoneType] = None) -> typing.Union[typing.Dict[datetime.datetime, NoneType], NoneType]

Parameters

country_code

Indicate which country/region's holiday infomation will be used for the check.

Returns

The dict with dates of holidays as the keys and None as values.

get_holidays_in_range(start_date: datetime.date, end_date: datetime.date, country_code: str = 'US') -> pandas.core.frame.DataFrame

Get a list of holiday infomation base on the given date range.

get_holidays_in_range(start_date: datetime.date, end_date: datetime.date, country_code: str = 'US') -> pandas.core.frame.DataFrame

Parameters

start_date

The start date of the date range.

end_date

The end date of the date range.

country_code

Indicate which country/region's holiday infomation will be used for the check.

Returns

A DataFrame which contains the holidays in the target date range.

get_holidays_in_range_by_country_or_region(start_date: datetime.date, end_date: datetime.date, country_or_region: str = 'United States') -> pandas.core.frame.DataFrame

Get a list of holiday infomation base on the given date range.

get_holidays_in_range_by_country_or_region(start_date: datetime.date, end_date: datetime.date, country_or_region: str = 'United States') -> pandas.core.frame.DataFrame

Parameters

start_date

The start date of the date range.

end_date

The end date of the date range.

country_or_region

Indicate which country/region's holiday infomation will be used for the check.

Returns

A DataFrame which contains the holidays in the target date range.

get_window_by_effect_gap(effect: str, gap: int) -> int

Generate holiday window number.

get_window_by_effect_gap(effect: str, gap: int) -> int

Parameters

effect

holiday window effect level

gap

the delta days between current holiday and the last/next holiday

is_holiday(target_date: datetime.date, country_code: str = 'US') -> bool

Detect a date is a holiday or not.

is_holiday(target_date: datetime.date, country_code: str = 'US') -> bool

Parameters

target_date

The date which needs to be check.

country_code

Indicate which country/region's holiday infomation will be used for the check.

Returns

Whether the target_date is a holiday or not. True or False.

is_holiday_by_country_or_region(target_date: datetime.date, country_or_region: str = 'United States') -> bool

Detect a date is a holiday or not.

is_holiday_by_country_or_region(target_date: datetime.date, country_or_region: str = 'United States') -> bool

Parameters

target_date

The date which needs to be check.

country_or_region

Indicate which country/region's holiday infomation will be used for the check.

Returns

Whether the target_date is a holiday or not. True or False.

update_holidays_by_adding_window() -> None

Generate the holidays csv with window into name.

update_holidays_by_adding_window() -> None

Attributes

HOLIDAYS_DF

HOLIDAYS_DF =        CountryOrRegion CountryCode  ...                       Name IsPaidTimeOff 0              Denmark          DK  ...                  Nytårsdag             0 1              Belgium          BE  ...              Nieuwjaarsdag             0 2          Netherlands          NL  ...              Nieuwjaarsdag             0 3              Croatia          HR  ...                Nova Godina             0 4                Czech          CZ  ...                   Nový rok             0 ...                ...         ...  ...                        ...           ... 344981         Croatia          HR  ...              Sveti Stjepan             0 344982          Norway          NO  ...  1 day after Andre juledag             0 344983          Sweden          SE  ...   1 day after Annandag jul             0 344984          Sweden          SE  ...                     Söndag             0 344985          Norway          NO  ...                     Søndag             0  [344986 rows x 5 columns]