From 57e15000e1113eae83ce365b4c111d319d56accb Mon Sep 17 00:00:00 2001 From: Dea Leon Date: Tue, 10 Jan 2023 17:38:26 +0100 Subject: [PATCH 1/5] Corrected docstrings --- pandas/core/arrays/categorical.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index abc3d9e8ce9db..6d907452b8f6d 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -935,7 +935,7 @@ def rename_categories(self, new_categories) -> Categorical: Returns ------- - cat : Categorical + Categorical Categorical with renamed categories. Raises @@ -1001,7 +1001,7 @@ def reorder_categories(self, new_categories, ordered=None): Returns ------- - cat : Categorical + Categorical Categorical with reordered categories. Raises @@ -1041,7 +1041,7 @@ def add_categories(self, new_categories) -> Categorical: Returns ------- - cat : Categorical + Categorical Categorical with new categories added. Raises @@ -1110,7 +1110,7 @@ def remove_categories(self, removals): Returns ------- - cat : Categorical + Categorical Categorical with removed categories. Raises @@ -1160,7 +1160,7 @@ def remove_unused_categories(self) -> Categorical: Returns ------- - cat : Categorical + Categorical Categorical with unused categories dropped. See Also From dc53b43e072ef2947fabf7e9e7545d1a36458346 Mon Sep 17 00:00:00 2001 From: Dea Leon Date: Tue, 10 Jan 2023 20:09:52 +0100 Subject: [PATCH 2/5] remove functions from code_checks.sh --- ci/code_checks.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 5d2f176d6bcd8..6df5d00d62afb 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -94,11 +94,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.Series.cat.remove_unused_categories \ pandas.Index.all \ pandas.Index.any \ - pandas.CategoricalIndex.rename_categories \ - pandas.CategoricalIndex.reorder_categories \ - pandas.CategoricalIndex.add_categories \ - pandas.CategoricalIndex.remove_categories \ - pandas.CategoricalIndex.remove_unused_categories \ pandas.MultiIndex.drop \ pandas.DatetimeIndex.to_pydatetime \ pandas.TimedeltaIndex.to_pytimedelta \ From 2b0151713b8bb7b498f0771c219b2b5a9cfd3bc7 Mon Sep 17 00:00:00 2001 From: Dea Leon Date: Tue, 17 Jan 2023 11:01:37 +0100 Subject: [PATCH 3/5] DOC Fix RT02 issues in docstrings GH49968 --- ci/code_checks.sh | 10 ---------- pandas/core/arrays/timedeltas.py | 2 +- pandas/core/groupby/groupby.py | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 6df5d00d62afb..400672d291e3a 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -85,27 +85,17 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (RT02)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=RT02 --ignore_functions \ - pandas.Series.align \ - pandas.Series.dt.total_seconds \ - pandas.Series.cat.rename_categories \ - pandas.Series.cat.reorder_categories \ - pandas.Series.cat.add_categories \ - pandas.Series.cat.remove_categories \ - pandas.Series.cat.remove_unused_categories \ pandas.Index.all \ pandas.Index.any \ pandas.MultiIndex.drop \ pandas.DatetimeIndex.to_pydatetime \ pandas.TimedeltaIndex.to_pytimedelta \ - pandas.core.groupby.SeriesGroupBy.apply \ - pandas.core.groupby.DataFrameGroupBy.apply \ pandas.io.formats.style.Styler.export \ pandas.api.extensions.ExtensionArray.astype \ pandas.api.extensions.ExtensionArray.dropna \ pandas.api.extensions.ExtensionArray.isna \ pandas.api.extensions.ExtensionArray.repeat \ pandas.api.extensions.ExtensionArray.unique \ - pandas.DataFrame.align RET=$(($RET + $?)) ; echo $MSG "DONE" fi diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index bc65d06789e5a..8e40a4aee6d41 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -728,7 +728,7 @@ def total_seconds(self) -> npt.NDArray[np.float64]: Returns ------- - seconds : [ndarray, Float64Index, Series] + [ndarray, Float64Index, Series] When the calling object is a TimedeltaArray, the return type is ndarray. When the calling object is a TimedeltaIndex, the return type is a Float64Index. When the calling object diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index dd7600c4dbf89..ccd6f95c2638f 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -173,7 +173,7 @@ class providing the base-class of operations. Returns ------- - applied : Series or DataFrame + Series or DataFrame See Also -------- From 523f3e4cf51ab57f6ba96996fd3dbeabae8df07a Mon Sep 17 00:00:00 2001 From: Dea Leon Date: Tue, 17 Jan 2023 11:45:49 +0100 Subject: [PATCH 4/5] DOC corrected docstring to comply with RT02 --- pandas/core/arrays/timedeltas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index 55f8ac554fa1a..7ed70d3e5438b 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -726,7 +726,7 @@ def total_seconds(self) -> npt.NDArray[np.float64]: Returns ------- - [ndarray, Float64Index, Series] + seconds : [ndarray, Float64Index, Series] When the calling object is a TimedeltaArray, the return type is ndarray. When the calling object is a TimedeltaIndex, the return type is a Float64Index. When the calling object @@ -781,7 +781,7 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]: Returns ------- - timedeltas : ndarray[object] + ndarray[object] """ return ints_to_pytimedelta(self._ndarray) From f72403a5e4e350e36e742cc069c51bdd8e85b343 Mon Sep 17 00:00:00 2001 From: Dea Leon Date: Wed, 18 Jan 2023 17:25:04 +0100 Subject: [PATCH 5/5] DOC correcting RT02 errors PR50785 --- ci/code_checks.sh | 2 +- pandas/core/arrays/timedeltas.py | 4 ++-- pandas/core/frame.py | 2 +- pandas/core/generic.py | 2 +- pandas/util/_decorators.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 400672d291e3a..0aee8cd546d47 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -95,7 +95,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.api.extensions.ExtensionArray.dropna \ pandas.api.extensions.ExtensionArray.isna \ pandas.api.extensions.ExtensionArray.repeat \ - pandas.api.extensions.ExtensionArray.unique \ + pandas.api.extensions.ExtensionArray.unique RET=$(($RET + $?)) ; echo $MSG "DONE" fi diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index 7ed70d3e5438b..1371472af34f8 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -726,7 +726,7 @@ def total_seconds(self) -> npt.NDArray[np.float64]: Returns ------- - seconds : [ndarray, Float64Index, Series] + ndarray, Float64Index or Series When the calling object is a TimedeltaArray, the return type is ndarray. When the calling object is a TimedeltaIndex, the return type is a Float64Index. When the calling object @@ -781,7 +781,7 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]: Returns ------- - ndarray[object] + timedeltas : ndarray[object] """ return ints_to_pytimedelta(self._ndarray) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index ebd4b278b79ca..26c8ab7d04749 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -11018,7 +11018,7 @@ def to_period( Returns ------- - DataFrame: + DataFrame The DataFrame has a PeriodIndex. Examples diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 700601cb4f024..d16446bbdf256 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -9123,7 +9123,7 @@ def align( Returns ------- - (left, right) : ({klass}, type of other) + tuple of ({klass}, type of other) Aligned objects. Examples diff --git a/pandas/util/_decorators.py b/pandas/util/_decorators.py index 571c065c53351..4a382f7984971 100644 --- a/pandas/util/_decorators.py +++ b/pandas/util/_decorators.py @@ -228,7 +228,7 @@ def _format_argument_list(allow_args: list[str]) -> str: Returns ------- - s : str + str The substring describing the argument list in best way to be inserted to the warning message.