pandas.tseries.holiday.before_nearest_workday#

pandas.tseries.holiday.before_nearest_workday(dt)[source]#

Move to the workday before the nearest workday.

nearest_workday runs first, so a Saturday holiday ends up on the Thursday before it.

Parameters:
dtdatetime

The date the holiday falls on.

Returns:
datetime

The date the holiday is observed on.

See also

tseries.holiday.nearest_workday

Move Saturday to Friday and Sunday to Monday.

tseries.holiday.after_nearest_workday

Move to the workday after the nearest workday.

tseries.holiday.previous_workday

Move to the previous weekday.

Examples

>>> from datetime import datetime
>>> from pandas.tseries.holiday import before_nearest_workday
>>> before_nearest_workday(datetime(2022, 1, 1))  # Saturday
datetime.datetime(2021, 12, 30, 0, 0)
>>> before_nearest_workday(datetime(2022, 1, 2))  # Sunday
datetime.datetime(2021, 12, 31, 0, 0)