PublicHolidaysOffline Class

Represents the Public Holidays Offline public dataset.

For a description of the rows, see the Public Holidays in the Microsoft Azure Open Datasets catalog.

Initialize filtering fields.

Inheritance
PublicHolidaysOffline

Constructor

PublicHolidaysOffline(country_or_region: str = 'US', start_date: datetime = datetime.datetime(1970, 1, 1, 0, 0), end_date: datetime = datetime.datetime(2099, 1, 1, 0, 0), cols: List[str] | None = None, enable_telemetry: bool = True)

Parameters

Name Description
country_or_region
str

The country or region to return data for.

Default value: US
start_date

The date at which to start loading data, inclusive. If None, the default_start_date is used.

Default value: 1970-01-01 00:00:00
end_date

The date at which to end loading data, inclusive. If None, the default_end_date is used.

Default value: 2099-01-01 00:00:00
cols

A list of columns names to load from the dataset. If None, all columns are loaded. For information on the available columns in this dataset, see Public Holidays.

Default value: None
enable_telemetry

Whether to enable telemetry on this dataset.

Default value: True
country_or_region
Required
str

The country or region you'd like to query against.

start_date
Required

The start date you'd like to query inclusively.

end_date
Required

The end date you'd like to query inclusively.

cols
Required

A list of column names you'd like to retrieve. None will get all columns.

enable_telemetry
Required

Indicates whether to send telemetry.

Remarks

The example below shows how to access the dataset.


   from azureml.opendatasets import PublicHolidaysOffline
   from datetime import datetime
   from dateutil.relativedelta import relativedelta

   end_date = datetime.today()
   start_date = datetime.today() - relativedelta(months=1)
   hol = PublicHolidaysOffline(start_date=start_date, end_date=end_date)
   hol_df = hol.to_pandas_dataframe()

Methods

filter

Filter time.

get_holidays_dates

Get a Dict with Key of the dates of holidays.

get_holidays_in_range

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

get_holidays_in_range_by_country_or_region

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

get_pandas_limit

Get instance of pandas data load limit class.

is_holiday

Detect a date is a holiday or not.

is_holiday_by_country_or_region

Detect a date is a holiday or not.

filter

Filter time.

filter(env: SparkEnv | PandasEnv, min_date: datetime, max_date: datetime)

Parameters

Name Description
env
Required

The runtime environment.

min_date
Required

The min date.

max_date
Required

The max date.

Returns

Type Description

The filtered data frame.

get_holidays_dates

Get a Dict with Key of the dates of holidays.

get_holidays_dates(country_code: str | None = None, country_or_region: str | None = None) -> Dict[datetime, None] | None

Parameters

Name Description
country_code

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

Default value: None
country_or_region

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

Default value: None

Returns

Type Description

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

get_holidays_in_range

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

get_holidays_in_range(start_date: date, end_date: date, country_code: str = 'US') -> DataFrame

Parameters

Name Description
start_date
Required

The start date of the date range.

end_date
Required

The end date of the date range.

country_code

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

Default value: US

Returns

Type Description

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

get_holidays_in_range_by_country_or_region

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

get_holidays_in_range_by_country_or_region(start_date: date, end_date: date, country_or_region: str = 'United States') -> DataFrame

Parameters

Name Description
start_date
Required

The start date of the date range.

end_date
Required

The end date of the date range.

country_or_region

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

Default value: United States

Returns

Type Description

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

get_pandas_limit

Get instance of pandas data load limit class.

get_pandas_limit()

is_holiday

Detect a date is a holiday or not.

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

Parameters

Name Description
target_date
Required

The date which needs to be check.

country_code

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

Default value: US

Returns

Type Description

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

is_holiday_by_country_or_region

Detect a date is a holiday or not.

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

Parameters

Name Description
target_date
Required

The date which needs to be check.

country_or_region

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

Default value: United States

Returns

Type Description

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

Attributes

HOLIDAYS_DF

HOLIDAYS_DF = countryOrRegion  ... isPaidTimeOff 0              Denmark  ...          None 1              Belgium  ...          None 2          Netherlands  ...          None 3              Croatia  ...          None 4                Czech  ...          None ...                ...  ...           ... 344981         Croatia  ...          None 344982          Norway  ...          None 344983          Sweden  ...          None 344984          Sweden  ...          None 344985          Norway  ...          None  [344986 rows x 5 columns]

data

data = None

default_country_or_region

default_country_or_region = 'US'

default_end_date

default_end_date = datetime.datetime(2099, 1, 1, 0, 0)

default_start_date

default_start_date = datetime.datetime(1970, 1, 1, 0, 0)