Skip to main content
`Ctrl`+`K`

# pandas.tseries.holiday.Holiday

class pandas.tseries.holiday.Holiday(name, year=None, month=None, day=None, offset=None, observance=None, start_date=None, end_date=None, days_of_week=None, exclude_dates=None)

  Class that defines a holiday with start/end dates and rules for observance.

  A `Holiday` can either be defined by a fixed `year`/`month`/`day`, or, more commonly, by a recurring `month`/`day` combined with an `offset` or `observance` rule that adjusts the date in each year it is calculated for. Instances of `Holiday` are typically collected in the `rules` of an `AbstractHolidayCalendar`.

  Parameters:
    name str

      Name of the holiday, defaults to class name.

    year int, default None

      Year of the holiday.

    month int, default None

      Month of the holiday.

    day int, default None

      Day of the holiday.

    offset DateOffset or list of DateOffset, default None

      Computes offset from date. See `pandas.tseries.offsets` for the available offset classes.

    observance function, default None

      Computes when holiday is given a pandas Timestamp.

    start_date datetime-like, default None

      First date the holiday is observed.

    end_date datetime-like, default None

      Last date the holiday is observed.

    days_of_week tuple of int or dateutil.relativedelta weekday strs, default None

      Provide a tuple of days e.g (0,1,2,3,) for Monday through Thursday Monday=0,..,Sunday=6 Only instances of the holiday included in days_of_week will be computed.

    exclude_dates DatetimeIndex or default None

      Specific dates to exclude e.g. skipping a specific year’s holiday.

  See also

  `tseries.holiday.AbstractHolidayCalendar`

    Abstract interface to create holidays following certain rules.

  `tseries.holiday.Holiday.dates`

    Calculate holidays observed between start date and end date.

  Examples

      >>> from dateutil.relativedelta import MO

      >>> USMemorialDay = pd.tseries.holiday.Holiday(
      ...     "Memorial Day", month=5, day=31, offset=pd.DateOffset(weekday=MO(-1))
      ... )
      >>> USMemorialDay
      Holiday: Memorial Day (month=5, day=31, offset=<DateOffset: weekday=MO(-1)>)

      >>> USLaborDay = pd.tseries.holiday.Holiday(
      ...     "Labor Day", month=9, day=1, offset=pd.DateOffset(weekday=MO(1))
      ... )
      >>> USLaborDay
      Holiday: Labor Day (month=9, day=1, offset=<DateOffset: weekday=MO(+1)>)

      >>> July3rd = pd.tseries.holiday.Holiday("July 3rd", month=7, day=3)
      >>> July3rd
      Holiday: July 3rd (month=7, day=3, )

      >>> NewYears = pd.tseries.holiday.Holiday(
      ...     "New Years Day",
      ...     month=1,
      ...     day=1,
      ...     observance=pd.tseries.holiday.nearest_workday,
      ... )
      >>> NewYears
      Holiday: New Years Day (
          month=1, day=1, observance=<function nearest_workday at 0x66545e9bc440>
      )

      >>> July3rd = pd.tseries.holiday.Holiday(
      ...     "July 3rd", month=7, day=3, days_of_week=(0, 1, 2, 3)
      ... )
      >>> July3rd
      Holiday: July 3rd (month=7, day=3, )

  Attributes

  Methods

  `dates`(start_date, end_date[, return_name]) | Calculate holidays observed between start date and end date.