diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 8e022ac662d21..82f134a348fee 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -2412,11 +2412,28 @@ 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 + -------- + :class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment. + Examples -------- - >>> ts = pd.Timestamp(2022, 1, 1) + >>> ts = pd.Timestamp(2022, 1, 30) >>> ts + pd.offsets.MonthEnd() Timestamp('2022-01-31 00:00:00') + + >>> ts = pd.Timestamp(2022, 1, 31) + >>> 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: + + >>> ts = pd.Timestamp(2022, 1, 31) + >>> ts + pd.offsets.MonthEnd(0) + Timestamp('2022-01-31 00:00:00') """ _period_dtype_code = PeriodDtypeCode.M _prefix = "M"