pandas.tseries.holiday.get_calendar#
- pandas.tseries.holiday.get_calendar(name)[source]#
Return an instance of a calendar based on its name.
The calendar class does not have to be kept around, since every calendar class is registered by name as soon as it is defined.
- Parameters:
- namestr
Calendar name to return an instance of. This is the class name, unless the class sets a
nameattribute.
- Returns:
- AbstractHolidayCalendar
A new instance of the registered calendar class.
- Raises:
- KeyError
If no calendar is registered under
name.
See also
tseries.holiday.registerAdd a holiday calendar class to the registry of named calendars.
tseries.holiday.HolidayCalendarFactoryCreate a holiday calendar class from two sets of rules.
tseries.holiday.AbstractHolidayCalendarAbstract interface to create holidays following certain rules.
Examples
>>> from pandas.tseries.holiday import ( ... AbstractHolidayCalendar, ... USLaborDay, ... get_calendar, ... ) >>> class MyCalendar(AbstractHolidayCalendar): ... rules = [USLaborDay] >>> cal = get_calendar("MyCalendar") >>> cal.holidays(start="2020-01-01", end="2020-12-31") DatetimeIndex(['2020-09-07'], dtype='datetime64[us]', freq=None)