Skip to content

Fixed up formatting of docstring of DateOffset #52354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1350,18 +1350,18 @@ class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
valid dates. For example, Bday(2) can be added to a date to move
it two business days forward. If the date does not start on a
valid date, first it is moved to a valid date. Thus pseudo code
is:
is::

def __add__(date):
date = rollback(date) # does nothing if date is valid
return date + <n number of periods>
def __add__(date):
date = rollback(date) # does nothing if date is valid
return date + <n number of periods>

When a date offset is created for a negative number of periods,
the date is first rolled forward. The pseudo code is:
the date is first rolled forward. The pseudo code is::

def __add__(date):
date = rollforward(date) # does nothing is date is valid
return date + <n number of periods>
def __add__(date):
date = rollforward(date) # does nothing if date is valid
return date + <n number of periods>

Zero presents a problem. Should it roll forward or back? We
arbitrarily have it rollforward:
Expand Down