Skip to content

Commit f05d217

Browse files
authored
DOC: add examples BusinessMonthEnd(0) and SemiMonthEnd(0) (#50027)
1 parent a85a386 commit f05d217

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

Diff for: pandas/_libs/tslibs/offsets.pyx

+32-10
Original file line numberDiff line numberDiff line change
@@ -2460,16 +2460,25 @@ cdef class BusinessMonthEnd(MonthOffset):
24602460
"""
24612461
DateOffset increments between the last business day of the month.
24622462
2463+
BusinessMonthEnd goes to the next date which is the last business day of the month.
2464+
To get the last business day of the current month pass the parameter n equals 0.
2465+
24632466
Examples
24642467
--------
2465-
>>> from pandas.tseries.offsets import BMonthEnd
2466-
>>> ts = pd.Timestamp('2020-05-24 05:01:15')
2467-
>>> ts + BMonthEnd()
2468-
Timestamp('2020-05-29 05:01:15')
2469-
>>> ts + BMonthEnd(2)
2470-
Timestamp('2020-06-30 05:01:15')
2471-
>>> ts + BMonthEnd(-2)
2472-
Timestamp('2020-03-31 05:01:15')
2468+
>>> ts = pd.Timestamp(2022, 11, 29)
2469+
>>> ts + pd.offsets.BMonthEnd()
2470+
Timestamp('2022-11-30 00:00:00')
2471+
2472+
>>> ts = pd.Timestamp(2022, 11, 30)
2473+
>>> ts + pd.offsets.BMonthEnd()
2474+
Timestamp('2022-12-30 00:00:00')
2475+
2476+
If you want to get the end of the current business month
2477+
pass the parameter n equals 0:
2478+
2479+
>>> ts = pd.Timestamp(2022, 11, 30)
2480+
>>> ts + pd.offsets.BMonthEnd(0)
2481+
Timestamp('2022-11-30 00:00:00')
24732482
"""
24742483
_prefix = "BM"
24752484
_day_opt = "business_end"
@@ -2642,11 +2651,24 @@ cdef class SemiMonthEnd(SemiMonthOffset):
26422651
26432652
Examples
26442653
--------
2645-
>>> ts = pd.Timestamp(2022, 1, 1)
2654+
>>> ts = pd.Timestamp(2022, 1, 14)
26462655
>>> ts + pd.offsets.SemiMonthEnd()
26472656
Timestamp('2022-01-15 00:00:00')
2648-
"""
26492657
2658+
>>> ts = pd.Timestamp(2022, 1, 15)
2659+
>>> ts + pd.offsets.SemiMonthEnd()
2660+
Timestamp('2022-01-31 00:00:00')
2661+
2662+
>>> ts = pd.Timestamp(2022, 1, 31)
2663+
>>> ts + pd.offsets.SemiMonthEnd()
2664+
Timestamp('2022-02-15 00:00:00')
2665+
2666+
If you want to get the result for the current month pass the parameter n equals 0:
2667+
2668+
>>> ts = pd.Timestamp(2022, 1, 15)
2669+
>>> ts + pd.offsets.SemiMonthEnd(0)
2670+
Timestamp('2022-01-15 00:00:00')
2671+
"""
26502672
_prefix = "SM"
26512673
_min_day_of_month = 1
26522674

0 commit comments

Comments
 (0)