Skip to content

DOC: update examples in MonthBegin/MonthEnd to use rollbackward/rollforward #52161

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 2 commits into from
Mar 24, 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
24 changes: 9 additions & 15 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2546,7 +2546,6 @@ cdef class MonthEnd(MonthOffset):
DateOffset of one month end.

MonthEnd goes to the next date which is an end of the month.
To get the end of the current month pass the parameter n equals 0.

See Also
--------
Expand All @@ -2562,10 +2561,10 @@ cdef class MonthEnd(MonthOffset):
>>> ts + pd.offsets.MonthEnd()
Timestamp('2022-02-28 00:00:00')

If you want to get the end of the current month pass the parameter n equals 0:
If you want to get the end of the current month:

>>> ts = pd.Timestamp(2022, 1, 31)
>>> ts + pd.offsets.MonthEnd(0)
>>> pd.offsets.MonthEnd().rollforward(ts)
Timestamp('2022-01-31 00:00:00')
"""
_period_dtype_code = PeriodDtypeCode.M
Expand All @@ -2578,7 +2577,6 @@ cdef class MonthBegin(MonthOffset):
DateOffset of one month at beginning.

MonthBegin goes to the next date which is a start of the month.
To get the start of the current month pass the parameter n equals 0.

See Also
--------
Expand All @@ -2594,10 +2592,10 @@ cdef class MonthBegin(MonthOffset):
>>> ts + pd.offsets.MonthBegin()
Timestamp('2023-01-01 00:00:00')

If you want to get the start of the current month pass the parameter n equals 0:
If you want to get the start of the current month:

>>> ts = pd.Timestamp(2022, 12, 1)
>>> ts + pd.offsets.MonthBegin(0)
>>> pd.offsets.MonthBegin().rollback(ts)
Timestamp('2022-12-01 00:00:00')
"""
_prefix = "MS"
Expand All @@ -2609,7 +2607,6 @@ cdef class BusinessMonthEnd(MonthOffset):
DateOffset increments between the last business day of the month.

BusinessMonthEnd goes to the next date which is the last business day of the month.
To get the last business day of the current month pass the parameter n equals 0.

Examples
--------
Expand All @@ -2621,11 +2618,10 @@ cdef class BusinessMonthEnd(MonthOffset):
>>> ts + pd.offsets.BMonthEnd()
Timestamp('2022-12-30 00:00:00')

If you want to get the end of the current business month
pass the parameter n equals 0:
If you want to get the end of the current business month:

>>> ts = pd.Timestamp(2022, 11, 30)
>>> ts + pd.offsets.BMonthEnd(0)
>>> pd.offsets.BMonthEnd().rollforward(ts)
Timestamp('2022-11-30 00:00:00')
"""
_prefix = "BM"
Expand All @@ -2637,8 +2633,7 @@ cdef class BusinessMonthBegin(MonthOffset):
DateOffset of one month at the first business day.

BusinessMonthBegin goes to the next date which is the first business day
of the month. To get the first business day of the current month pass
the parameter n equals 0.
of the month.

Examples
--------
Expand All @@ -2650,11 +2645,10 @@ cdef class BusinessMonthBegin(MonthOffset):
>>> ts + pd.offsets.BMonthBegin()
Timestamp('2023-01-02 00:00:00')

If you want to get the start of the current business month pass
the parameter n equals 0:
If you want to get the start of the current business month:

>>> ts = pd.Timestamp(2022, 12, 1)
>>> ts + pd.offsets.BMonthBegin(0)
>>> pd.offsets.BMonthBegin().rollback(ts)
Timestamp('2022-12-01 00:00:00')
"""
_prefix = "BMS"
Expand Down