Skip to content

DOC: fixup formatting of docstring of DateOffset #52325

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

Closed
1 task done
MarcoGorelli opened this issue Mar 31, 2023 · 3 comments · Fixed by #52354
Closed
1 task done

DOC: fixup formatting of docstring of DateOffset #52325

MarcoGorelli opened this issue Mar 31, 2023 · 3 comments · Fixed by #52354

Comments

@MarcoGorelli
Copy link
Member

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

@choudharynishu
Copy link
Contributor

Can I try taking on this issue?

@MarcoGorelli
Copy link
Member Author

sure thing, thanks!

@choudharynishu
Copy link
Contributor

choudharynishu commented Mar 31, 2023

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants