Date offsets#

BaseOffset#

BaseOffset

Base class for all pandas date offsets.

Properties#

BaseOffset.freqstr

Return a string representing the frequency.

BaseOffset.kwds

Return a dict of extra parameters for the offset.

BaseOffset.name

(DEPRECATED) Return a string representing the base frequency.

BaseOffset.nanos

Return an integer of the total number of nanoseconds.

BaseOffset.normalize

Return boolean whether the frequency can align with midnight.

BaseOffset.rule_code

Return a string representing the base frequency.

BaseOffset.n

Return the count of the number of periods.

Methods#

BaseOffset.copy()

Return a copy of the frequency.

BaseOffset.is_on_offset(dt)

Return boolean whether a timestamp intersects with this frequency.

BaseOffset.is_month_start(ts)

Return boolean whether a timestamp occurs on the month start.

BaseOffset.is_month_end(ts)

Return boolean whether a timestamp occurs on the month end.

BaseOffset.is_quarter_start(ts)

Return boolean whether a timestamp occurs on the quarter start.

BaseOffset.is_quarter_end(ts)

Return boolean whether a timestamp occurs on the quarter end.

BaseOffset.is_year_start(ts)

Return boolean whether a timestamp occurs on the year start.

BaseOffset.is_year_end(ts)

Return boolean whether a timestamp occurs on the year end.

BaseOffset.rollback(dt)

Roll provided date backward to next offset only if not on offset.

BaseOffset.rollforward(dt)

Roll provided date forward to next offset only if not on offset.

DateOffset#

DateOffset

Standard kind of date increment used for a date range.

BusinessDay#

BusinessDay([n, normalize, offset])

DateOffset subclass representing possibly n business days.

BDay

Custom properties:

BusinessDay.offset

Return the time offset applied to the business day.

BusinessDay.weekmask

Return the weekmask used for custom business day calculations.

BusinessDay.holidays

Return the holidays used for custom business day calculations.

BusinessDay.calendar

Return the calendar used for business day calculations.

BusinessHour#

BusinessHour

DateOffset subclass representing possibly n business hours.

Custom properties:

BusinessHour.offset

Return the time offset applied to the business day.

BusinessHour.start

Return the start time(s) of the business hour.

BusinessHour.end

Return the end time(s) of the business hour.

BusinessHour.weekmask

Return the weekmask used for custom business day calculations.

BusinessHour.holidays

Return the holidays used for custom business day calculations.

BusinessHour.calendar

Return the calendar used for business day calculations.

CustomBusinessDay#

CustomBusinessDay([n, normalize, weekmask, ...])

DateOffset subclass representing possibly n custom business days.

CDay

Custom properties:

CustomBusinessDay.weekmask

Return the weekmask used for custom business day calculations.

CustomBusinessDay.calendar

Return the calendar used for business day calculations.

CustomBusinessDay.holidays

Return the holidays used for custom business day calculations.

CustomBusinessDay.offset

Return the time offset applied to the business day.

CustomBusinessHour#

CustomBusinessHour

DateOffset subclass representing possibly n custom business days.

Custom properties:

CustomBusinessHour.weekmask

Return the weekmask used for custom business day calculations.

CustomBusinessHour.calendar

Return the calendar used for business day calculations.

CustomBusinessHour.holidays

Return the holidays used for custom business day calculations.

CustomBusinessHour.start

Return the start time(s) of the business hour.

CustomBusinessHour.end

Return the end time(s) of the business hour.

CustomBusinessHour.offset

Return the time offset applied to the business day.

Month offsets#

MonthEnd

DateOffset of one month end.

MonthBegin

DateOffset of one month at beginning.

Business variants:

BusinessMonthEnd

DateOffset increments between the last business day of the month.

BMonthEnd

BusinessMonthBegin

DateOffset of one month at the first business day.

BMonthBegin

CustomBusinessMonthEnd#

CustomBusinessMonthEnd([n, normalize, ...])

DateOffset subclass representing custom business month(s).

CBMonthEnd

Custom properties:

CustomBusinessMonthEnd.m_offset

Return a MonthBegin or MonthEnd offset.

CustomBusinessMonthEnd.weekmask

Return the weekmask used for custom business day calculations.

CustomBusinessMonthEnd.calendar

Return the calendar used for business day calculations.

CustomBusinessMonthEnd.holidays

Return the holidays used for custom business day calculations.

CustomBusinessMonthEnd.offset

Return the time offset applied to the business day.

CustomBusinessMonthBegin#

CustomBusinessMonthBegin([n, normalize, ...])

DateOffset subclass representing custom business month(s).

CBMonthBegin

Custom properties:

CustomBusinessMonthBegin.m_offset

Return a MonthBegin or MonthEnd offset.

CustomBusinessMonthBegin.weekmask

Return the weekmask used for custom business day calculations.

CustomBusinessMonthBegin.calendar

Return the calendar used for business day calculations.

CustomBusinessMonthBegin.holidays

Return the holidays used for custom business day calculations.

CustomBusinessMonthBegin.offset

Return the time offset applied to the business day.

SemiMonthEnd#

SemiMonthEnd

Two DateOffset's per month repeating on the last day of the month & day_of_month.

SemiMonthBegin

Two DateOffset's per month repeating on the first day of the month & day_of_month.

Custom properties:

SemiMonthEnd.day_of_month

Return the day of the month for the semi-monthly offset.

SemiMonthBegin.day_of_month

Return the day of the month for the semi-monthly offset.

Week#

Week

Weekly offset.

Custom properties:

Week.weekday

Return the day of the week on which the offset is applied.

WeekOfMonth#

WeekOfMonth

Describes monthly dates like "the Tuesday of the 2nd week of each month".

Custom properties:

WeekOfMonth.week

Return the week of the month on which this offset applies.

WeekOfMonth.weekday

Return the day of the week on which this offset applies.

LastWeekOfMonth#

LastWeekOfMonth

Describes monthly dates in last week of month.

Custom properties:

LastWeekOfMonth.week

Return the week of the month on which this offset applies.

LastWeekOfMonth.weekday

Return the day of the week on which this offset applies.

Quarter offsets#

QuarterEnd

DateOffset increments between Quarter end dates.

QuarterBegin

DateOffset increments between Quarter start dates.

BQuarterEnd

DateOffset increments between the last business day of each Quarter.

BQuarterBegin

DateOffset increments between the first business day of each Quarter.

Custom properties:

BQuarterEnd.startingMonth

Return the month of the year that anchors the quarters.

BQuarterBegin.startingMonth

Return the month of the year that anchors the quarters.

QuarterEnd.startingMonth

Return the month of the year that anchors the quarters.

QuarterBegin.startingMonth

Return the month of the year that anchors the quarters.

HalfYear offsets#

HalfYearEnd

DateOffset increments between half-year end dates.

HalfYearBegin

DateOffset increments between half-year start dates.

BHalfYearEnd

DateOffset increments between the last business day of each half-year.

BHalfYearBegin

DateOffset increments between the first business day of each half-year.

Custom properties:

BHalfYearEnd.startingMonth

Return the month of the year that anchors the half-years.

BHalfYearBegin.startingMonth

Return the month of the year that anchors the half-years.

HalfYearEnd.startingMonth

Return the month of the year that anchors the half-years.

HalfYearBegin.startingMonth

Return the month of the year that anchors the half-years.

Year offsets#

YearEnd([n, normalize, month])

DateOffset increments between calendar year end dates.

YearBegin

DateOffset increments between calendar year begin dates.

BYearEnd

DateOffset increments between the last business day of the year.

BYearBegin

DateOffset increments between the first business day of the year.

Custom properties:

YearEnd.month

Return the month of the year on which this offset applies.

YearBegin.month

Return the month of the year on which this offset applies.

BYearEnd.month

Return the month of the year on which this offset applies.

BYearBegin.month

Return the month of the year on which this offset applies.

FY5253#

FY5253

Describes 52-53 week fiscal year.

Custom properties:

FY5253.startingMonth

Return the starting month of the fiscal year.

FY5253.variation

Return the variation of the fiscal year.

FY5253.weekday

Return the weekday used by the fiscal year.

Custom methods:

FY5253.get_rule_code_suffix()

Return the suffix component of the rule code.

FY5253.get_year_end(dt)

Get the fiscal year end date for the given datetime.

FY5253Quarter#

FY5253Quarter

DateOffset increments between business quarter dates for 52-53 week fiscal year.

Custom properties:

FY5253Quarter.qtr_with_extra_week

Return the quarter number that has the leap or 14 week when needed.

FY5253Quarter.startingMonth

Return the starting month of the fiscal year.

FY5253Quarter.variation

Return the variation of the fiscal year.

FY5253Quarter.weekday

Return the weekday used by the fiscal year.

Custom methods:

FY5253Quarter.get_rule_code_suffix()

Return the suffix component of the rule code.

FY5253Quarter.get_weeks(dt)

Get the number of weeks in each quarter for the fiscal year containing dt.

FY5253Quarter.year_has_extra_week(dt)

Return whether the fiscal year containing the given date has 53 weeks.

Easter#

Easter

DateOffset for the Easter holiday using logic defined in dateutil.

Ticks#

Tick

Base class for fixed frequency offsets (Milli, Micro, Second, Minute, Hour).

Day

Offset n days.

Hour

Offset n hours.

Minute

Offset n minutes.

Second

Offset n seconds.

Milli

Offset n milliseconds.

Micro

Offset n microseconds.

Nano

Offset n nanoseconds.

Frequencies#

to_offset(freq[, is_period])

Return DateOffset object from string or datetime.timedelta object.

Holiday calendars#

Holiday#

Holiday(name[, year, month, day, offset, ...])

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

Methods#

Holiday.dates(start_date, end_date[, ...])

Calculate holidays observed between start date and end date.

Calendars#

AbstractHolidayCalendar([name, rules])

Abstract interface to create holidays following certain rules.

USFederalHolidayCalendar([name, rules])

US Federal Government holiday calendar.

Methods#

AbstractHolidayCalendar.holidays([start, ...])

Return a curve with holidays between start_date and end_date.

AbstractHolidayCalendar.merge(other[, inplace])

Merge holiday calendars together.

AbstractHolidayCalendar.merge_class(base, other)

Merge holiday calendars together.

AbstractHolidayCalendar.rule_from_name(name)

Return the rule for the holiday with the given name.

Observance rules#

after_nearest_workday(dt)

Move to the workday after the nearest workday.

before_nearest_workday(dt)

Move to the workday before the nearest workday.

nearest_workday(dt)

Move Saturday to Friday and Sunday to Monday.

next_monday(dt)

Move Saturday and Sunday to the following Monday.

next_monday_or_tuesday(dt)

Move Saturday to Monday, and Sunday or Monday to Tuesday.

next_workday(dt)

Move to the next weekday.

previous_friday(dt)

Move Saturday and Sunday back to the previous Friday.

previous_workday(dt)

Move to the previous weekday.

sunday_to_monday(dt)

Move Sunday to the following Monday.

weekend_to_monday(dt)

Move Saturday and Sunday to the following Monday.

Calendar utilities#

HolidayCalendarFactory(name, base, other[, ...])

Create a holiday calendar class from two sets of rules.

get_calendar(name)

Return an instance of a calendar based on its name.

register(cls)

Add a holiday calendar class to the registry of named calendars.