Skip to content

Commit 13f758c

Browse files
authored
48779-doc-MonthEnd (#49958)
* 48779-doc-MonthEnd * 48779-doc-MonthEnd-I * DOC: add example MonthEnd(0)
1 parent 4d0a436 commit 13f758c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pandas/_libs/tslibs/offsets.pyx

+18-1
Original file line numberDiff line numberDiff line change
@@ -2412,11 +2412,28 @@ cdef class MonthEnd(MonthOffset):
24122412
"""
24132413
DateOffset of one month end.
24142414
2415+
MonthEnd goes to the next date which is an end of the month.
2416+
To get the end of the current month pass the parameter n equals 0.
2417+
2418+
See Also
2419+
--------
2420+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
2421+
24152422
Examples
24162423
--------
2417-
>>> ts = pd.Timestamp(2022, 1, 1)
2424+
>>> ts = pd.Timestamp(2022, 1, 30)
24182425
>>> ts + pd.offsets.MonthEnd()
24192426
Timestamp('2022-01-31 00:00:00')
2427+
2428+
>>> ts = pd.Timestamp(2022, 1, 31)
2429+
>>> ts + pd.offsets.MonthEnd()
2430+
Timestamp('2022-02-28 00:00:00')
2431+
2432+
If you want to get the end of the current month pass the parameter n equals 0:
2433+
2434+
>>> ts = pd.Timestamp(2022, 1, 31)
2435+
>>> ts + pd.offsets.MonthEnd(0)
2436+
Timestamp('2022-01-31 00:00:00')
24202437
"""
24212438
_period_dtype_code = PeriodDtypeCode.M
24222439
_prefix = "M"

0 commit comments

Comments
 (0)