Skip to content

DOC: fixup formatting of docstring of DateOffset #52325

Closed
@MarcoGorelli

Description

@MarcoGorelli

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/dev/reference/api/pandas.tseries.offsets.DateOffset.html

Documentation problem

The docstring formatting looks wrong, some of it should probably render as code, given how it's written

This is the part of code you need to modify:

DateOffsets can be created to move dates forward a given number of
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:
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:
def __add__(date):
date = rollforward(date) # does nothing is date is valid
return date + <n number of periods>
Zero presents a problem. Should it roll forward or back? We
arbitrarily have it rollforward:

Suggested fix for documentation

Render the code example as code

You should be able to build it by doing

python make.py --single pandas.tseries.offsets.DateOffset

from the doc folder

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions