From cd36acb58955d47307c0a93019df7b4564d9c022 Mon Sep 17 00:00:00 2001 From: uditbaliyan Date: Wed, 28 Aug 2024 23:57:08 +0530 Subject: [PATCH 1/7] fix pandas.Timestamp.fold GL08 --- pandas/_libs/tslibs/timestamps.pyx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index ec976f17af396..10d0d423b2471 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -984,6 +984,31 @@ cdef class _Timestamp(ABCTimestamp): """ return super().day + @property + def fold(self) -> int: + """ + Return the fold value of the Timestamp, which indicates whether the time is in the + fold of a transition (typically during daylight saving time transitions). + + Returns + ------- + int + The fold value of the Timestamp, where 0 indicates the first occurrence + of the ambiguous time, and 1 indicates the second. + + See Also + -------- + Timestamp.dst : Return the daylight saving time (DST) adjustment. + Timestamp.tzinfo : Return the timezone information associated with the Timestamp. + + Examples + -------- + >>> ts = pd.Timestamp("2024-11-03 01:30:00", fold=1, tz="America/New_York") + >>> ts.fold + 1 + """ + return super().fold + @property def month(self) -> int: """ From 609eac360d3f4ee7cf758fc0121a96f29d90f655 Mon Sep 17 00:00:00 2001 From: uditbaliyan Date: Wed, 28 Aug 2024 23:58:06 +0530 Subject: [PATCH 2/7] fix pandas.Timestamp.fold GL08 --- pandas/_libs/tslibs/timestamps.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 10d0d423b2471..5e1c1ed43d576 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1003,9 +1003,9 @@ cdef class _Timestamp(ABCTimestamp): Examples -------- - >>> ts = pd.Timestamp("2024-11-03 01:30:00", fold=1, tz="America/New_York") + >>> ts = pd.Timestamp("2024-11-03 01:30:00") >>> ts.fold - 1 + 0 """ return super().fold From 787f28f44b0ebf543076daa3b14e39d1a8452387 Mon Sep 17 00:00:00 2001 From: uditbaliyan Date: Thu, 29 Aug 2024 00:04:47 +0530 Subject: [PATCH 3/7] remove i- pandas.Timestamp.fold GL08 --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 324305417a600..9012dc6559a13 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -132,7 +132,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.TimedeltaIndex.nanoseconds SA01" \ -i "pandas.TimedeltaIndex.seconds SA01" \ -i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \ - -i "pandas.Timestamp.fold GL08" \ -i "pandas.Timestamp.max PR02" \ -i "pandas.Timestamp.min PR02" \ -i "pandas.Timestamp.nanosecond GL08" \ From 3a14167089ac612366543a70556cb00ee3eecc40 Mon Sep 17 00:00:00 2001 From: uditbaliyan Date: Thu, 29 Aug 2024 00:24:55 +0530 Subject: [PATCH 4/7] fix pre-commit error --- pandas/_libs/tslibs/timestamps.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 5e1c1ed43d576..97ec333f0abfd 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -987,19 +987,19 @@ cdef class _Timestamp(ABCTimestamp): @property def fold(self) -> int: """ - Return the fold value of the Timestamp, which indicates whether the time is in the - fold of a transition (typically during daylight saving time transitions). + Return the fold value of the Timestamp, + which indicates whether the time is in the fold of a transition. Returns ------- int - The fold value of the Timestamp, where 0 indicates the first occurrence + The fold value of the Timestamp, where 0 indicates the first occurrence of the ambiguous time, and 1 indicates the second. See Also -------- Timestamp.dst : Return the daylight saving time (DST) adjustment. - Timestamp.tzinfo : Return the timezone information associated with the Timestamp. + Timestamp.tzinfo : Return the timezone information associated. Examples -------- From 220b75f8416f57a45d388a732ebe7a9a304c6926 Mon Sep 17 00:00:00 2001 From: uditbaliyan Date: Thu, 29 Aug 2024 00:49:25 +0530 Subject: [PATCH 5/7] fix docstring error --- pandas/_libs/tslibs/timestamps.pyx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 97ec333f0abfd..bdcb5e751c2a8 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -987,8 +987,7 @@ cdef class _Timestamp(ABCTimestamp): @property def fold(self) -> int: """ - Return the fold value of the Timestamp, - which indicates whether the time is in the fold of a transition. + Return the fold value of the Timestamp. Returns ------- From 61d50d39bc49cfd557ebad22c36f1f858e733b65 Mon Sep 17 00:00:00 2001 From: uditbaliyan Date: Wed, 4 Sep 2024 22:52:02 +0530 Subject: [PATCH 6/7] add see also for ceil,floor,asm8,round --- pandas/_libs/tslibs/timedeltas.pyx | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index d5348311f19e2..36be1812b0187 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1498,6 +1498,12 @@ cdef class _Timedelta(timedelta): numpy timedelta64 array scalar view Array scalar view of the timedelta in nanoseconds. + See Also + -------- + Timedelta.total_seconds : Return the total seconds in the duration. + Timedelta.components : Return a namedtuple of the Timedelta's components. + Timedelta.to_timedelta64 : Convert the Timedelta to a numpy.timedelta64. + Examples -------- >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') @@ -2061,6 +2067,12 @@ class Timedelta(_Timedelta): ------ ValueError if the freq cannot be converted + See Also + -------- + Timedelta.floor : Floor the Timedelta to the specified resolution. + Timedelta.round : Round the Timedelta to the nearest specified resolution. + Timestamp.ceil : Similar method for Timestamp objects. + Examples -------- >>> td = pd.Timedelta('1001ms') @@ -2081,6 +2093,16 @@ class Timedelta(_Timedelta): Frequency string indicating the flooring resolution. It uses the same units as class constructor :class:`~pandas.Timedelta`. + Returns + ------- + Timedelta + A new Timedelta object floored to the specified resolution. + + See Also + -------- + Timestamp.ceil : Round the Timestamp up to the nearest specified resolution. + Timestamp.round : Round the Timestamp to the nearest specified resolution. + Examples -------- >>> td = pd.Timedelta('1001ms') @@ -2101,6 +2123,16 @@ class Timedelta(_Timedelta): Frequency string indicating the ceiling resolution. It uses the same units as class constructor :class:`~pandas.Timedelta`. + Returns + ------- + Timedelta + A new Timedelta object ceiled to the specified resolution. + + See Also + -------- + Timedelta.floor : Floor the Timedelta to the specified resolution. + Timedelta.round : Round the Timedelta to the nearest specified resolution. + Examples -------- >>> td = pd.Timedelta('1001ms') From 2765ee1c7bde4a0fd7db0fb1e800c1b75393708c Mon Sep 17 00:00:00 2001 From: uditbaliyan Date: Wed, 4 Sep 2024 22:54:12 +0530 Subject: [PATCH 7/7] remove ceil,floor,asm8,round from code_checks.sh --- ci/code_checks.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index b009212084dde..0714c6f74f0c2 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -109,14 +109,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.sparse.from_coo PR07,SA01" \ -i "pandas.Series.sparse.npoints SA01" \ -i "pandas.Series.sparse.sp_values SA01" \ - -i "pandas.Timedelta.asm8 SA01" \ - -i "pandas.Timedelta.ceil SA01" \ -i "pandas.Timedelta.components SA01" \ - -i "pandas.Timedelta.floor SA01" \ -i "pandas.Timedelta.max PR02" \ -i "pandas.Timedelta.min PR02" \ -i "pandas.Timedelta.resolution PR02" \ - -i "pandas.Timedelta.round SA01" \ -i "pandas.Timedelta.to_numpy PR01" \ -i "pandas.Timedelta.to_timedelta64 SA01" \ -i "pandas.Timedelta.total_seconds SA01" \