pandas.tseries.holiday.AbstractHolidayCalendar#
- class pandas.tseries.holiday.AbstractHolidayCalendar(name='', rules=None)[source]#
Abstract interface to create holidays following certain rules.
A subclass normally defines its holidays by setting
rulesto a list ofHolidayinstances directly on the class body. Alternatively, a set of rules can be passed to the constructor. The calendar can then be used to compute the holiday dates falling within a given date range viaholidays().- Parameters:
- namestr
Name of the holiday calendar, defaults to class name.
- rulesarray of Holiday objects
A set of rules used to create the holidays.
See also
tseries.holiday.HolidayClass that defines a holiday with start/end dates and rules for observance.
tseries.offsets.CustomBusinessDayDateOffset subclass representing possibly n business days excluding holidays.
Examples
>>> from pandas.tseries.holiday import AbstractHolidayCalendar, USLaborDay >>> class MyCalendar(AbstractHolidayCalendar): ... rules = [USLaborDay] >>> MyCalendar().holidays(start="2020-01-01", end="2020-12-31") DatetimeIndex(['2020-09-07'], dtype='datetime64[us]', freq=None)
Attributes
end_daterulesstart_dateMethods
holidays([start, end, return_name])Return a curve with holidays between start_date and end_date.
merge(other[, inplace])Merge holiday calendars together.
merge_class(base, other)Merge holiday calendars together.
rule_from_name(name)Return the rule for the holiday with the given name.