From 778ef437fe895c2a1f38e6aad783b380b6dc9b08 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Thu, 17 Aug 2023 23:56:39 +0200 Subject: [PATCH 1/3] docs: add examples to offsets classes FY5253, FY5253Quarter --- pandas/_libs/tslibs/offsets.pyx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 958fe1181d309..5af36869ef6da 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -3567,6 +3567,10 @@ cdef class FY5253(FY5253Mixin): >>> ts = pd.Timestamp(2022, 1, 1) >>> ts + pd.offsets.FY5253() Timestamp('2022-01-31 00:00:00') + + >>> ts = pd.Timestamp(2022, 1, 1) + >>> ts + pd.offsets.FY5253(startingMonth=1, weekday=3, variation="nearest") + Timestamp('2022-02-03 00:00:00') """ _prefix = "RE" @@ -3750,6 +3754,11 @@ cdef class FY5253Quarter(FY5253Mixin): >>> ts = pd.Timestamp(2022, 1, 1) >>> ts + pd.offsets.FY5253Quarter() Timestamp('2022-01-31 00:00:00') + + >>> ts = pd.Timestamp(2022, 1, 1) + >>> ts + pd.offsets.FY5253Quarter(weekday=5, startingMonth=12, variation="last", + ... qtr_with_extra_week=4) + Timestamp('2022-03-26 00:00:00') """ _prefix = "REQ" From 3dcefcd3baf812c7a58ef2f05b0b7001cfe81fbd Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Fri, 18 Aug 2023 15:51:50 +0200 Subject: [PATCH 2/3] add examples, see also section, a description for parameter n --- pandas/_libs/tslibs/offsets.pyx | 44 +++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 5af36869ef6da..616694d86be56 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -3540,6 +3540,7 @@ cdef class FY5253(FY5253Mixin): Parameters ---------- n : int + The number of fiscal years represented. weekday : int {0, 1, ..., 6}, default 0 A specific integer for the day of the week. @@ -3562,15 +3563,31 @@ cdef class FY5253(FY5253Mixin): - "nearest" means year end is **weekday** closest to last day of month in year. - "last" means year end is final **weekday** of the final month in fiscal year. + See Also + -------- + :class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment. + Examples -------- + In the example below the default parameters give the next 52-53 week fiscal year. + >>> ts = pd.Timestamp(2022, 1, 1) >>> ts + pd.offsets.FY5253() Timestamp('2022-01-31 00:00:00') + By the parameter ``startingMonth`` we can specify + the month in which fiscal years end. + >>> ts = pd.Timestamp(2022, 1, 1) - >>> ts + pd.offsets.FY5253(startingMonth=1, weekday=3, variation="nearest") - Timestamp('2022-02-03 00:00:00') + >>> ts + pd.offsets.FY5253(startingMonth=3) + Timestamp('2022-03-28 00:00:00') + + 52-53 week fiscal year can be specified by + ``weekday`` and ``variation`` parameters. + + >>> ts = pd.Timestamp(2022, 1, 1) + >>> ts + pd.offsets.FY5253(weekday=5, startingMonth=12, variation="last") + Timestamp('2022-12-31 00:00:00') """ _prefix = "RE" @@ -3724,6 +3741,7 @@ cdef class FY5253Quarter(FY5253Mixin): Parameters ---------- n : int + The number of business quarters represented. weekday : int {0, 1, ..., 6}, default 0 A specific integer for the day of the week. @@ -3749,16 +3767,32 @@ cdef class FY5253Quarter(FY5253Mixin): - "nearest" means year end is **weekday** closest to last day of month in year. - "last" means year end is final **weekday** of the final month in fiscal year. + See Also + -------- + :class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment. + Examples -------- + In the example below the default parameters give + the next business quarter for 52-53 week fiscal year. + >>> ts = pd.Timestamp(2022, 1, 1) >>> ts + pd.offsets.FY5253Quarter() Timestamp('2022-01-31 00:00:00') + By the parameter ``startingMonth`` we can specify + the month in which fiscal years end. + + >>> ts = pd.Timestamp(2022, 1, 1) + >>> ts + pd.offsets.FY5253Quarter(startingMonth=3) + Timestamp('2022-03-28 00:00:00') + + Business quarters for 52-53 week fiscal year can be specified by + ``weekday`` and ``variation`` parameters. + >>> ts = pd.Timestamp(2022, 1, 1) - >>> ts + pd.offsets.FY5253Quarter(weekday=5, startingMonth=12, variation="last", - ... qtr_with_extra_week=4) - Timestamp('2022-03-26 00:00:00') + >>> ts + pd.offsets.FY5253Quarter(weekday=5, startingMonth=12, variation="last") + Timestamp('2022-04-02 00:00:00') """ _prefix = "REQ" From ddbcc0d9eeef95c8661531940c107eb8d6d5236a Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Fri, 18 Aug 2023 22:22:04 +0200 Subject: [PATCH 3/3] add missing parameter normalize --- pandas/_libs/tslibs/offsets.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 616694d86be56..9be582be3caa8 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -3541,6 +3541,8 @@ cdef class FY5253(FY5253Mixin): ---------- n : int The number of fiscal years represented. + normalize : bool, default False + Normalize start/end dates to midnight before generating date range. weekday : int {0, 1, ..., 6}, default 0 A specific integer for the day of the week. @@ -3742,6 +3744,8 @@ cdef class FY5253Quarter(FY5253Mixin): ---------- n : int The number of business quarters represented. + normalize : bool, default False + Normalize start/end dates to midnight before generating date range. weekday : int {0, 1, ..., 6}, default 0 A specific integer for the day of the week.