pandas.tseries.holiday.previous_friday#
- pandas.tseries.holiday.previous_friday(dt)[source]#
Move Saturday and Sunday back to the previous Friday.
A holiday on a weekday keeps its date.
- Parameters:
- dtdatetime
The date the holiday falls on.
- Returns:
- datetime
The date the holiday is observed on.
See also
tseries.holiday.next_mondayMove Saturday and Sunday to the following Monday.
tseries.holiday.previous_workdayMove to the previous weekday.
tseries.holiday.HolidayClass that defines a holiday with start/end dates and rules for observance.
Examples
>>> from datetime import datetime >>> from pandas.tseries.holiday import previous_friday >>> previous_friday(datetime(2022, 1, 1)) # Saturday datetime.datetime(2021, 12, 31, 0, 0) >>> previous_friday(datetime(2022, 1, 2)) # Sunday datetime.datetime(2021, 12, 31, 0, 0)