From ef0539f689d4a4708bc8b5c8f7ffb71d428e7849 Mon Sep 17 00:00:00 2001 From: luke <2736230899@qq.com> Date: Thu, 29 Dec 2022 16:12:03 +0800 Subject: [PATCH 1/5] CLEAN dubious docstring Fixes #50344 --- pandas/_libs/tslibs/offsets.pyx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 3ff50be966fa0..491900bba69e7 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -382,25 +382,26 @@ cdef class BaseOffset: # dict _cache def __init__(self, n=1, normalize=False): - n = self._validate_n(n) - self.n = n """ - Number of multiples of the frequency. + Parameters: + ----------- + n : int + Number of multiples of the frequency. + + normalize : boolean + Whether the frequency can align with midnight. Examples -------- >>> pd.offsets.Hour(5).n 5 - """ - self.normalize = normalize - """ - Return boolean whether the frequency can align with midnight. - Examples - -------- >>> pd.offsets.Hour(5).normalize False """ + n = self._validate_n(n) + self.n = n + self.normalize = normalize self._cache = {} def __eq__(self, other) -> bool: From ac3f5cdf9bff0066207f0ed9ee703aee06dc02b2 Mon Sep 17 00:00:00 2001 From: luke <2736230899@qq.com> Date: Thu, 29 Dec 2022 16:36:26 +0800 Subject: [PATCH 2/5] moving docstring --- pandas/_libs/tslibs/offsets.pyx | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 491900bba69e7..1ef6ed06cb86b 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -366,6 +366,22 @@ class ApplyTypeError(TypeError): cdef class BaseOffset: """ Base class for DateOffset methods that are not overridden by subclasses. + + Parameters: + ----------- + n : int + Number of multiples of the frequency. + + normalize : boolean + Whether the frequency can align with midnight. + + Examples + -------- + >>> pd.offsets.Hour(5).n + 5 + + >>> pd.offsets.Hour(5).normalize + False """ # ensure that reversed-ops with numpy scalars return NotImplemented __array_priority__ = 1000 @@ -382,23 +398,6 @@ cdef class BaseOffset: # dict _cache def __init__(self, n=1, normalize=False): - """ - Parameters: - ----------- - n : int - Number of multiples of the frequency. - - normalize : boolean - Whether the frequency can align with midnight. - - Examples - -------- - >>> pd.offsets.Hour(5).n - 5 - - >>> pd.offsets.Hour(5).normalize - False - """ n = self._validate_n(n) self.n = n self.normalize = normalize From 2ed5ab2c345bda1e18405f530b146ca37d671ffd Mon Sep 17 00:00:00 2001 From: luke396 <77875500+luke396@users.noreply.github.com> Date: Thu, 29 Dec 2022 18:36:05 +0800 Subject: [PATCH 3/5] Update pandas/_libs/tslibs/offsets.pyx Co-authored-by: Marc Garcia --- pandas/_libs/tslibs/offsets.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 1ef6ed06cb86b..6adfb49fed59e 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -367,8 +367,8 @@ cdef class BaseOffset: """ Base class for DateOffset methods that are not overridden by subclasses. - Parameters: - ----------- + Parameters + ---------- n : int Number of multiples of the frequency. From 14461860a4f243a7f96ae7ff8f4aea5b850dc320 Mon Sep 17 00:00:00 2001 From: luke396 <77875500+luke396@users.noreply.github.com> Date: Thu, 29 Dec 2022 18:36:19 +0800 Subject: [PATCH 4/5] Update pandas/_libs/tslibs/offsets.pyx Co-authored-by: Marc Garcia --- pandas/_libs/tslibs/offsets.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 6adfb49fed59e..b1f7fdd801dc4 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -372,7 +372,7 @@ cdef class BaseOffset: n : int Number of multiples of the frequency. - normalize : boolean + normalize : bool Whether the frequency can align with midnight. Examples From cf1e574d1cc9f10a7a42f24cadf7d15067cc8301 Mon Sep 17 00:00:00 2001 From: luke396 <77875500+luke396@users.noreply.github.com> Date: Thu, 29 Dec 2022 18:36:29 +0800 Subject: [PATCH 5/5] Update pandas/_libs/tslibs/offsets.pyx Co-authored-by: Marc Garcia --- pandas/_libs/tslibs/offsets.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index b1f7fdd801dc4..0bc9751694e9f 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -379,7 +379,6 @@ cdef class BaseOffset: -------- >>> pd.offsets.Hour(5).n 5 - >>> pd.offsets.Hour(5).normalize False """