From 82b00150d0b43fc1745e811ce34e585d902771f4 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Mon, 28 Nov 2022 16:56:51 +0100 Subject: [PATCH 1/3] 48779-doc-MonthEnd --- pandas/_libs/tslibs/offsets.pyx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 8e022ac662d21..23720b93d27a6 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -2410,13 +2410,19 @@ cdef class MonthOffset(SingleConstructorOffset): cdef class MonthEnd(MonthOffset): """ - DateOffset of one month end. + 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: MonthEnd(0). 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') """ _period_dtype_code = PeriodDtypeCode.M _prefix = "M" From a95e4944cbff74dc56533f1c234527cd36048661 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Tue, 29 Nov 2022 15:53:18 +0100 Subject: [PATCH 2/3] 48779-doc-MonthEnd-I --- pandas/_libs/tslibs/offsets.pyx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 23720b93d27a6..9a3583b51f3d0 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -2410,19 +2410,23 @@ cdef class MonthOffset(SingleConstructorOffset): 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: MonthEnd(0). + 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. Examples -------- >>> 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" From c73cdfec26a024cd08f0beb34e22956e0ab2b6b0 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Wed, 30 Nov 2022 11:20:38 +0100 Subject: [PATCH 3/3] DOC: add example MonthEnd(0) --- pandas/_libs/tslibs/offsets.pyx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 9a3583b51f3d0..82f134a348fee 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -2415,15 +2415,22 @@ cdef class MonthEnd(MonthOffset): 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, 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')