From 3ab9678a4ad2a2bfd38146f609675deceb5a3eaf Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 31 Mar 2024 23:40:34 +0200 Subject: [PATCH 1/8] Add results information to unstack method docstring. --- pandas/core/frame.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 50a93994dc76b..2575b23630e11 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -9658,6 +9658,8 @@ def unstack( Returns ------- Series or DataFrame + If index is a MultiIndex: DataFrame with pivoted index labels as new + inner-most level column labels, else Series. See Also -------- From 6047539d25fd64c1aebfff592f8e22ff3a096def Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 31 Mar 2024 23:51:45 +0200 Subject: [PATCH 2/8] Add result docstring to value_counts method. --- pandas/core/frame.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 2575b23630e11..abb8d13342c9d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7162,7 +7162,7 @@ def value_counts( dropna: bool = True, ) -> Series: """ - Return a Series containing the frequency of each distinct row in the Dataframe. + Return a Series containing the frequency of each distinct row in the DataFrame. Parameters ---------- @@ -7175,13 +7175,14 @@ def value_counts( ascending : bool, default False Sort in ascending order. dropna : bool, default True - Don't include counts of rows that contain NA values. + Do not include counts of rows that contain NA values. .. versionadded:: 1.3.0 Returns ------- Series + Series containing the frequency of each distinct row in the DataFrame. See Also -------- @@ -7192,8 +7193,8 @@ def value_counts( The returned Series will have a MultiIndex with one level per input column but an Index (non-multi) for a single label. By default, rows that contain any NA values are omitted from the result. By default, - the resulting Series will be in descending order so that the first - element is the most frequently-occurring row. + the resulting Series will be sorted by frequencies in descending order so that + the first element is the most frequently-occurring row. Examples -------- From 1193ef523a7a417f16231e6b9f1e16ce0c1d6f18 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Mon, 1 Apr 2024 00:26:21 +0200 Subject: [PATCH 3/8] Add See also section to DataFrame.tz_localize method. --- pandas/core/generic.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 858d2ba82a969..59b9a0f025016 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10485,10 +10485,10 @@ def tz_localize( nonexistent: TimeNonexistent = "raise", ) -> Self: """ - Localize tz-naive index of a Series or DataFrame to target time zone. + Localize time zone naive index of a Series or DataFrame to target time zone. This operation localizes the Index. To localize the values in a - timezone-naive Series, use :meth:`Series.dt.tz_localize`. + time zone naive Series, use :meth:`Series.dt.tz_localize`. Parameters ---------- @@ -10548,7 +10548,13 @@ def tz_localize( Returns ------- {klass} - Same type as the input. + Same type as the input, with time zone naive or aware index, depending on + ``tz``. + + See Also + -------- + Series.dt.tz_localize: localize the values in a time zone naive Series. + Timestamp.tz_localize: localize the Timestamp to a timezone. Raises ------ From 93e29025f60a1c18e65497718c2d3fce25982446 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Mon, 1 Apr 2024 01:07:17 +0200 Subject: [PATCH 4/8] Add See also section for unstack method of Series. --- pandas/core/base.py | 1 + pandas/core/series.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pandas/core/base.py b/pandas/core/base.py index 263265701691b..f923106e967b7 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -924,6 +924,7 @@ def value_counts( Returns ------- Series + Series containing counts of unique values. See Also -------- diff --git a/pandas/core/series.py b/pandas/core/series.py index b0dc05fce7913..843788273a6ef 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4257,6 +4257,10 @@ def unstack( DataFrame Unstacked Series. + See Also + -------- + DataFrame.unstack : Pivot the MultiIndex of a DataFrame. + Notes ----- Reference :ref:`the user guide ` for more examples. From ecccdd3e53f48b2254297da943c334a5cb233791 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Mon, 1 Apr 2024 01:10:32 +0200 Subject: [PATCH 5/8] Remove methods from code check ignore list --- ci/code_checks.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 0c4e6641444f1..425677411c25c 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -127,9 +127,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.DataFrame.to_period SA01" \ -i "pandas.DataFrame.to_timestamp SA01" \ -i "pandas.DataFrame.tz_convert SA01" \ - -i "pandas.DataFrame.tz_localize SA01" \ - -i "pandas.DataFrame.unstack RT03" \ - -i "pandas.DataFrame.value_counts RT03" \ -i "pandas.DataFrame.var PR01,RT03,SA01" \ -i "pandas.DataFrame.where RT03" \ -i "pandas.DatetimeIndex.ceil SA01" \ @@ -482,8 +479,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.to_timestamp RT03,SA01" \ -i "pandas.Series.truediv PR07" \ -i "pandas.Series.tz_convert SA01" \ - -i "pandas.Series.tz_localize SA01" \ - -i "pandas.Series.unstack SA01" \ -i "pandas.Series.update PR07,SA01" \ -i "pandas.Series.value_counts RT03" \ -i "pandas.Series.var PR01,RT03,SA01" \ @@ -570,7 +565,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timestamp.toordinal SA01" \ -i "pandas.Timestamp.tz SA01" \ -i "pandas.Timestamp.tz_convert SA01" \ - -i "pandas.Timestamp.tz_localize SA01" \ -i "pandas.Timestamp.tzinfo GL08" \ -i "pandas.Timestamp.tzname SA01" \ -i "pandas.Timestamp.unit SA01" \ From 6815e6d50ed178fba40a71219180b8dfafcb243b Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Mon, 1 Apr 2024 12:00:16 +0200 Subject: [PATCH 6/8] Fix order of docstring sections. --- pandas/core/generic.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 59b9a0f025016..f16325559a612 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10551,16 +10551,16 @@ def tz_localize( Same type as the input, with time zone naive or aware index, depending on ``tz``. - See Also - -------- - Series.dt.tz_localize: localize the values in a time zone naive Series. - Timestamp.tz_localize: localize the Timestamp to a timezone. - Raises ------ TypeError If the TimeSeries is tz-aware and tz is not None. + See Also + -------- + Series.dt.tz_localize: localize the values in a time zone naive Series. + Timestamp.tz_localize: localize the Timestamp to a timezone. + Examples -------- Localize local times: From b3cfd045805803101113b0f6dc59d8b5ea2b8316 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Mon, 1 Apr 2024 13:00:39 +0200 Subject: [PATCH 7/8] Fix further validation errors. --- ci/code_checks.sh | 2 -- pandas/core/generic.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 425677411c25c..05cc2d685c488 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -223,7 +223,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index.to_list RT03" \ -i "pandas.Index.union PR07,RT03,SA01" \ -i "pandas.Index.unique RT03" \ - -i "pandas.Index.value_counts RT03" \ -i "pandas.Index.view GL08" \ -i "pandas.Int16Dtype SA01" \ -i "pandas.Int32Dtype SA01" \ @@ -480,7 +479,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.truediv PR07" \ -i "pandas.Series.tz_convert SA01" \ -i "pandas.Series.update PR07,SA01" \ - -i "pandas.Series.value_counts RT03" \ -i "pandas.Series.var PR01,RT03,SA01" \ -i "pandas.Series.where RT03" \ -i "pandas.SparseDtype SA01" \ diff --git a/pandas/core/generic.py b/pandas/core/generic.py index f16325559a612..ee1ce2f817b6c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10558,8 +10558,8 @@ def tz_localize( See Also -------- - Series.dt.tz_localize: localize the values in a time zone naive Series. - Timestamp.tz_localize: localize the Timestamp to a timezone. + Series.dt.tz_localize: Localize the values in a time zone naive Series. + Timestamp.tz_localize: Localize the Timestamp to a timezone. Examples -------- From 7a413a6b3d006961e2098cb9527eaaf7cd46a3b9 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Mon, 1 Apr 2024 13:59:19 +0200 Subject: [PATCH 8/8] Reinsert method to ignore list. --- ci/code_checks.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 05cc2d685c488..a9f69ee4f6c57 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -563,6 +563,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timestamp.toordinal SA01" \ -i "pandas.Timestamp.tz SA01" \ -i "pandas.Timestamp.tz_convert SA01" \ + -i "pandas.Timestamp.tz_localize SA01" \ -i "pandas.Timestamp.tzinfo GL08" \ -i "pandas.Timestamp.tzname SA01" \ -i "pandas.Timestamp.unit SA01" \