From c56b6ade7f35d78f66f2e0b6f5c3a478430d0553 Mon Sep 17 00:00:00 2001 From: Katsiaryna Date: Thu, 22 Aug 2024 22:10:34 +0100 Subject: [PATCH 1/7] fix pandas.Series.dt.freq --- pandas/core/indexes/accessors.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index e2dc71f68a65b..0f3840a72c8dd 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -373,6 +373,36 @@ def to_pydatetime(self) -> Series: @property def freq(self): + """ + Return the frequency object if it is set, otherwise None. + + To learn more about the frequency strings, please see + :ref:`this link`. + + See Also + -------- + DatetimeIndex.freq : Return the frequency object if it is set, otherwise None. + PeriodIndex.freq : Return the frequency object if it is set, otherwise None. + + Examples + -------- + >>> datetimeindex = pd.Series( + ... [ + ... "2022-02-22 02:22:22-06:00", + ... "2022-02-22 03:22:22-06:00", + ... "2022-02-22 04:22:22-06:00", + ... "2022-02-22 05:22:22-06:00", + ... "2022-02-22 06:22:22-06:00", + ... "2022-02-22 07:22:22-06:00", + ... "2022-02-22 08:22:22-06:00", + ... "2022-02-22 09:22:22-06:00", + ... "2022-02-22 10:22:22-06:00", + ... "2022-02-22 11:22:22-06:00", + ... ] + ... ) + >>> datetimeindex.freq + + """ return self._get_values().inferred_freq def isocalendar(self) -> DataFrame: From 6c10ff8caa1e6c05f4a02741f5f56df1df02d93c Mon Sep 17 00:00:00 2001 From: Katsiaryna Date: Thu, 22 Aug 2024 22:42:43 +0100 Subject: [PATCH 2/7] fix seconds, nanoseconds, microseconds --- pandas/core/arrays/timedeltas.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index b2cfbe7338c0d..e7f2ee0ea0d71 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -842,6 +842,11 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]: seconds_docstring = textwrap.dedent( """Number of seconds (>= 0 and less than 1 day) for each element. + See Also + -------- + Series.dt.seconds : Return number of seconds for each element. + Series.dt.nanoseconds : Return number of nanoseconds for each element. + Examples -------- For Series: @@ -876,6 +881,11 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]: microseconds_docstring = textwrap.dedent( """Number of microseconds (>= 0 and less than 1 second) for each element. + See Also + -------- + Series.dt.seconds : Return number of seconds for each element. + Series.dt.nanoseconds : Return number of nanoseconds for each element. + Examples -------- For Series: @@ -911,6 +921,11 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]: nanoseconds_docstring = textwrap.dedent( """Number of nanoseconds (>= 0 and less than 1 microsecond) for each element. + See Also + -------- + Series.dt.seconds : Return number of seconds for each element. + Series.dt.microseconds : Return number of nanoseconds for each element. + Examples -------- For Series: From 8180bb7285460c0af321432d8775ac53aa4a5645 Mon Sep 17 00:00:00 2001 From: Katsiaryna Date: Thu, 22 Aug 2024 22:45:27 +0100 Subject: [PATCH 3/7] remove fixed objects 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 e9f4ee1f391a2..5367bac2a40be 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -119,14 +119,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.ceil PR01,PR02" \ -i "pandas.Series.dt.day_name PR01,PR02" \ -i "pandas.Series.dt.floor PR01,PR02" \ - -i "pandas.Series.dt.freq GL08" \ - -i "pandas.Series.dt.microseconds SA01" \ -i "pandas.Series.dt.month_name PR01,PR02" \ - -i "pandas.Series.dt.nanoseconds SA01" \ -i "pandas.Series.dt.normalize PR01" \ -i "pandas.Series.dt.qyear GL08" \ -i "pandas.Series.dt.round PR01,PR02" \ - -i "pandas.Series.dt.seconds SA01" \ -i "pandas.Series.dt.strftime PR01,PR02" \ -i "pandas.Series.dt.to_period PR01,PR02" \ -i "pandas.Series.dt.total_seconds PR01" \ From e026a6cc092738b6f5cd2b385e315d68fdb1d4f2 Mon Sep 17 00:00:00 2001 From: Katsiaryna Date: Fri, 23 Aug 2024 19:32:18 +0100 Subject: [PATCH 4/7] Remove Timedelta Index checks --- ci/code_checks.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 5367bac2a40be..538285dd02c1f 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -171,9 +171,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timedelta.view SA01" \ -i "pandas.TimedeltaIndex.as_unit RT03,SA01" \ -i "pandas.TimedeltaIndex.components SA01" \ - -i "pandas.TimedeltaIndex.microseconds SA01" \ - -i "pandas.TimedeltaIndex.nanoseconds SA01" \ - -i "pandas.TimedeltaIndex.seconds SA01" \ -i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \ -i "pandas.Timestamp.day GL08" \ -i "pandas.Timestamp.fold GL08" \ From f55730276d39feea600d984142cdd39269a7aa83 Mon Sep 17 00:00:00 2001 From: Katsiaryna Date: Fri, 23 Aug 2024 19:45:55 +0100 Subject: [PATCH 5/7] fix freq example --- pandas/core/indexes/accessors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 0f3840a72c8dd..35dba09bbe4b5 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -400,7 +400,7 @@ def freq(self): ... "2022-02-22 11:22:22-06:00", ... ] ... ) - >>> datetimeindex.freq + >>> datetimeindex.dt.freq """ return self._get_values().inferred_freq From 2e1efed013c9e1a9a5579ac2b83fd0b8f33e8c72 Mon Sep 17 00:00:00 2001 From: Katsiaryna Date: Sat, 7 Sep 2024 00:15:16 +0100 Subject: [PATCH 6/7] remove freq --- ci/code_checks.sh | 1 + pandas/core/indexes/accessors.py | 30 ------------------------------ 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 538285dd02c1f..2343f80ab699e 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -119,6 +119,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.ceil PR01,PR02" \ -i "pandas.Series.dt.day_name PR01,PR02" \ -i "pandas.Series.dt.floor PR01,PR02" \ + -i "pandas.Series.dt.freq GL08" \ -i "pandas.Series.dt.month_name PR01,PR02" \ -i "pandas.Series.dt.normalize PR01" \ -i "pandas.Series.dt.qyear GL08" \ diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 35dba09bbe4b5..e2dc71f68a65b 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -373,36 +373,6 @@ def to_pydatetime(self) -> Series: @property def freq(self): - """ - Return the frequency object if it is set, otherwise None. - - To learn more about the frequency strings, please see - :ref:`this link`. - - See Also - -------- - DatetimeIndex.freq : Return the frequency object if it is set, otherwise None. - PeriodIndex.freq : Return the frequency object if it is set, otherwise None. - - Examples - -------- - >>> datetimeindex = pd.Series( - ... [ - ... "2022-02-22 02:22:22-06:00", - ... "2022-02-22 03:22:22-06:00", - ... "2022-02-22 04:22:22-06:00", - ... "2022-02-22 05:22:22-06:00", - ... "2022-02-22 06:22:22-06:00", - ... "2022-02-22 07:22:22-06:00", - ... "2022-02-22 08:22:22-06:00", - ... "2022-02-22 09:22:22-06:00", - ... "2022-02-22 10:22:22-06:00", - ... "2022-02-22 11:22:22-06:00", - ... ] - ... ) - >>> datetimeindex.dt.freq - - """ return self._get_values().inferred_freq def isocalendar(self) -> DataFrame: From 3d4d94d4a1986f5fcf8a52076ae9c4a30d0abf04 Mon Sep 17 00:00:00 2001 From: Katsiaryna Date: Sat, 7 Sep 2024 00:19:04 +0100 Subject: [PATCH 7/7] bring back microseconds --- ci/code_checks.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 2343f80ab699e..4e2461cc1de09 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -120,6 +120,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.day_name PR01,PR02" \ -i "pandas.Series.dt.floor PR01,PR02" \ -i "pandas.Series.dt.freq GL08" \ + -i "pandas.Series.dt.microseconds SA01" \ -i "pandas.Series.dt.month_name PR01,PR02" \ -i "pandas.Series.dt.normalize PR01" \ -i "pandas.Series.dt.qyear GL08" \ @@ -172,6 +173,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timedelta.view SA01" \ -i "pandas.TimedeltaIndex.as_unit RT03,SA01" \ -i "pandas.TimedeltaIndex.components SA01" \ + -i "pandas.TimedeltaIndex.microseconds SA01" \ -i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \ -i "pandas.Timestamp.day GL08" \ -i "pandas.Timestamp.fold GL08" \