Skip to content

Commit 97c3a45

Browse files
authored
DOC: #38067 add missing holiday observance rules (#57939)
* fix method docstrings * add observances to user guide * add weekend_to_monday to user guide
1 parent ec9a98e commit 97c3a45

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

doc/source/user_guide/timeseries.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1468,11 +1468,16 @@ or some other non-observed day. Defined observance rules are:
14681468
:header: "Rule", "Description"
14691469
:widths: 15, 70
14701470

1471+
"next_workday", "move Saturday and Sunday to Monday"
1472+
"previous_workday", "move Saturday and Sunday to Friday"
14711473
"nearest_workday", "move Saturday to Friday and Sunday to Monday"
1474+
"before_nearest_workday", "apply ``nearest_workday`` and then move to previous workday before that day"
1475+
"after_nearest_workday", "apply ``nearest_workday`` and then move to next workday after that day"
14721476
"sunday_to_monday", "move Sunday to following Monday"
14731477
"next_monday_or_tuesday", "move Saturday to Monday and Sunday/Monday to Tuesday"
14741478
"previous_friday", move Saturday and Sunday to previous Friday"
14751479
"next_monday", "move Saturday and Sunday to following Monday"
1480+
"weekend_to_monday", "same as ``next_monday``"
14761481

14771482
An example of how holidays and holiday calendars are defined:
14781483

pandas/tseries/holiday.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def nearest_workday(dt: datetime) -> datetime:
108108

109109
def next_workday(dt: datetime) -> datetime:
110110
"""
111-
returns next weekday used for observances
111+
returns next workday used for observances
112112
"""
113113
dt += timedelta(days=1)
114114
while dt.weekday() > 4:
@@ -119,7 +119,7 @@ def next_workday(dt: datetime) -> datetime:
119119

120120
def previous_workday(dt: datetime) -> datetime:
121121
"""
122-
returns previous weekday used for observances
122+
returns previous workday used for observances
123123
"""
124124
dt -= timedelta(days=1)
125125
while dt.weekday() > 4:
@@ -130,7 +130,7 @@ def previous_workday(dt: datetime) -> datetime:
130130

131131
def before_nearest_workday(dt: datetime) -> datetime:
132132
"""
133-
returns previous workday after nearest workday
133+
returns previous workday before nearest workday
134134
"""
135135
return previous_workday(nearest_workday(dt))
136136

0 commit comments

Comments
 (0)