From cd36acb58955d47307c0a93019df7b4564d9c022 Mon Sep 17 00:00:00 2001 From: uditbaliyan Date: Wed, 28 Aug 2024 23:57:08 +0530 Subject: [PATCH 1/5] 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/5] 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/5] 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/5] 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/5] 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 -------