Skip to content
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
42 changes: 32 additions & 10 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2460,16 +2460,25 @@ 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
--------
>>> from pandas.tseries.offsets import BMonthEnd
>>> ts = pd.Timestamp('2020-05-24 05:01:15')
>>> ts + BMonthEnd()
Timestamp('2020-05-29 05:01:15')
>>> ts + BMonthEnd(2)
Timestamp('2020-06-30 05:01:15')
>>> ts + BMonthEnd(-2)
Timestamp('2020-03-31 05:01:15')
>>> ts = pd.Timestamp(2022, 11, 29)
>>> ts + pd.offsets.BMonthEnd()
Timestamp('2022-11-30 00:00:00')

>>> ts = pd.Timestamp(2022, 11, 30)
>>> 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:

>>> ts = pd.Timestamp(2022, 11, 30)
>>> ts + pd.offsets.BMonthEnd(0)
Timestamp('2022-11-30 00:00:00')
"""
_prefix = "BM"
_day_opt = "business_end"
Expand Down Expand Up @@ -2642,11 +2651,24 @@ cdef class SemiMonthEnd(SemiMonthOffset):

Examples
--------
>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts = pd.Timestamp(2022, 1, 14)
>>> ts + pd.offsets.SemiMonthEnd()
Timestamp('2022-01-15 00:00:00')
"""

>>> ts = pd.Timestamp(2022, 1, 15)
>>> ts + pd.offsets.SemiMonthEnd()
Timestamp('2022-01-31 00:00:00')

>>> ts = pd.Timestamp(2022, 1, 31)
>>> ts + pd.offsets.SemiMonthEnd()
Timestamp('2022-02-15 00:00:00')

If you want to get the result for the current month pass the parameter n equals 0:

>>> ts = pd.Timestamp(2022, 1, 15)
>>> ts + pd.offsets.SemiMonthEnd(0)
Timestamp('2022-01-15 00:00:00')
"""
_prefix = "SM"
_min_day_of_month = 1

Expand Down