From cc5cdd8ed07e5cb4cd9c72fa329807f25f9374ee Mon Sep 17 00:00:00 2001 From: hlakams Date: Sun, 25 Aug 2024 06:20:28 -0700 Subject: [PATCH 1/6] DOCS: pandas.Series.prod + pandas.Series.product RT03 docstring validation error fixed --- ci/code_checks.sh | 2 -- pandas/core/generic.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index e9f4ee1f391a2..0e89cd10a4c2e 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -141,8 +141,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.ne SA01" \ -i "pandas.Series.pad PR01,SA01" \ -i "pandas.Series.pop SA01" \ - -i "pandas.Series.prod RT03" \ - -i "pandas.Series.product RT03" \ -i "pandas.Series.reorder_levels RT03,SA01" \ -i "pandas.Series.sem PR01,RT03,SA01" \ -i "pandas.Series.sparse PR01,SA01" \ diff --git a/pandas/core/generic.py b/pandas/core/generic.py index cdc8642c9c70e..61fa5c49a8c5b 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -11815,6 +11815,8 @@ def last_valid_index(self) -> Hashable: Returns ------- {name1} or scalar\ + + Value containing the calculation referenced in the description.\ {see_also}\ {examples} """ From 8d8caa9e6a5bfd7f7752ac6ad6f8265fd07296f6 Mon Sep 17 00:00:00 2001 From: hlakams Date: Sun, 25 Aug 2024 06:49:58 -0700 Subject: [PATCH 2/6] DOCS: pandas.Series.pop SA01 + pandas.Series.reorder_levels RT03/SA01 docstring validation error fixed --- ci/code_checks.sh | 2 -- pandas/core/series.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 0e89cd10a4c2e..d9ab81a7cca03 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -140,8 +140,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.lt SA01" \ -i "pandas.Series.ne SA01" \ -i "pandas.Series.pad PR01,SA01" \ - -i "pandas.Series.pop SA01" \ - -i "pandas.Series.reorder_levels RT03,SA01" \ -i "pandas.Series.sem PR01,RT03,SA01" \ -i "pandas.Series.sparse PR01,SA01" \ -i "pandas.Series.sparse.density SA01" \ diff --git a/pandas/core/series.py b/pandas/core/series.py index 5c35c6c0d6d23..749e1dbda7425 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4093,7 +4093,12 @@ def reorder_levels(self, order: Sequence[Level]) -> Series: Returns ------- - type of caller (new object) + Series + Type of caller with index as MultiIndex (new object). + + See Also + -------- + DataFrame.reorder_levels : Rearrange index or column levels using input ``order``. Examples -------- @@ -5048,6 +5053,11 @@ def pop(self, item: Hashable) -> Any: scalar Value that is popped from series. + See Also + -------- + Series.drop: Drop specified values from Series. + Series.drop_duplicates: Return Series with duplicate values removed. + Examples -------- >>> ser = pd.Series([1, 2, 3]) From 1c32b9589569565c037568a0909c644dbbb8ac9f Mon Sep 17 00:00:00 2001 From: hlakams Date: Sun, 25 Aug 2024 06:51:57 -0700 Subject: [PATCH 3/6] DOCS: pandas.Series.list.__getitem__ + pandas.Series.list.flatten + pandas.Series.list.len SA01 docstring validation error fixed --- ci/code_checks.sh | 3 --- pandas/core/arrays/arrow/accessors.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index d9ab81a7cca03..6e2f94bb264e7 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -134,9 +134,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.tz_localize PR01,PR02" \ -i "pandas.Series.dt.unit GL08" \ -i "pandas.Series.gt SA01" \ - -i "pandas.Series.list.__getitem__ SA01" \ - -i "pandas.Series.list.flatten SA01" \ - -i "pandas.Series.list.len SA01" \ -i "pandas.Series.lt SA01" \ -i "pandas.Series.ne SA01" \ -i "pandas.Series.pad PR01,SA01" \ diff --git a/pandas/core/arrays/arrow/accessors.py b/pandas/core/arrays/arrow/accessors.py index d8f948a37d206..3dd3465f2c9eb 100644 --- a/pandas/core/arrays/arrow/accessors.py +++ b/pandas/core/arrays/arrow/accessors.py @@ -92,6 +92,12 @@ def len(self) -> Series: pandas.Series The length of each list. + See Also + -------- + str.len : Python built-in function returning the length of an object. + Series.size : Returns the length of the Series. + StringMethods.len : Compute the length of each element in the Series/Index. + Examples -------- >>> import pyarrow as pa @@ -128,6 +134,10 @@ def __getitem__(self, key: int | slice) -> Series: pandas.Series The list at requested index. + See Also + -------- + ListAccessor.flatten : Flatten list values. + Examples -------- >>> import pyarrow as pa @@ -187,6 +197,10 @@ def flatten(self) -> Series: pandas.Series The data from all lists in the series flattened. + See Also + -------- + ListAccessor.__getitem__ : Index or slice values in the Series. + Examples -------- >>> import pyarrow as pa From 83262b7455cdb3a7cadedbe2952480a3f2fa0f8b Mon Sep 17 00:00:00 2001 From: hlakams Date: Sun, 25 Aug 2024 06:52:43 -0700 Subject: [PATCH 4/6] DOCS: pandas.Series.sparse.density SA01 docstring validation error fixed --- ci/code_checks.sh | 1 - pandas/core/arrays/sparse/array.py | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 6e2f94bb264e7..d970fe9916610 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -139,7 +139,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.pad PR01,SA01" \ -i "pandas.Series.sem PR01,RT03,SA01" \ -i "pandas.Series.sparse PR01,SA01" \ - -i "pandas.Series.sparse.density SA01" \ -i "pandas.Series.sparse.fill_value SA01" \ -i "pandas.Series.sparse.from_coo PR07,SA01" \ -i "pandas.Series.sparse.npoints SA01" \ diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index 3a08344369822..3e94cf09e3ca3 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -671,6 +671,11 @@ def density(self) -> float: """ The percent of non- ``fill_value`` points, as decimal. + See Also + -------- + DataFrame.sparse.from_spmatrix : Create a new DataFrame from a + scipy sparse matrix. + Examples -------- >>> from pandas.arrays import SparseArray From 75d7b470c6558933aed2e9d3e3e914497c91d497 Mon Sep 17 00:00:00 2001 From: hlakams Date: Sun, 25 Aug 2024 07:09:23 -0700 Subject: [PATCH 5/6] DOCS: pandas.Series.gt + pandas.Series.lt + pandas.Series.ne SA01 docstring validation error fixed --- ci/code_checks.sh | 3 --- pandas/core/ops/docstrings.py | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index d970fe9916610..0cb2df7bb334b 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -133,9 +133,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.tz_convert PR01,PR02" \ -i "pandas.Series.dt.tz_localize PR01,PR02" \ -i "pandas.Series.dt.unit GL08" \ - -i "pandas.Series.gt SA01" \ - -i "pandas.Series.lt SA01" \ - -i "pandas.Series.ne SA01" \ -i "pandas.Series.pad PR01,SA01" \ -i "pandas.Series.sem PR01,RT03,SA01" \ -i "pandas.Series.sparse PR01,SA01" \ diff --git a/pandas/core/ops/docstrings.py b/pandas/core/ops/docstrings.py index 0ad6db0aefe9c..5ce0a2da86f31 100644 --- a/pandas/core/ops/docstrings.py +++ b/pandas/core/ops/docstrings.py @@ -376,7 +376,7 @@ def make_flex_doc(op_name: str, typ: str) -> str: "ne": { "op": "!=", "desc": "Not equal to", - "reverse": None, + "reverse": "eq", "series_examples": _ne_example_SERIES, "series_returns": _returns_series, }, @@ -397,14 +397,14 @@ def make_flex_doc(op_name: str, typ: str) -> str: "gt": { "op": ">", "desc": "Greater than", - "reverse": None, + "reverse": "lt", "series_examples": _gt_example_SERIES, "series_returns": _returns_series, }, "ge": { "op": ">=", "desc": "Greater than or equal to", - "reverse": None, + "reverse": "le", "series_examples": _ge_example_SERIES, "series_returns": _returns_series, }, From e703c54fef51c552bc81fa3eb7d204d5e27c4ae5 Mon Sep 17 00:00:00 2001 From: hlakams Date: Sun, 25 Aug 2024 07:27:34 -0700 Subject: [PATCH 6/6] linting issues leftover from docstring validation fixes resolved --- pandas/core/arrays/arrow/accessors.py | 4 ++-- pandas/core/arrays/sparse/array.py | 2 +- pandas/core/series.py | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pandas/core/arrays/arrow/accessors.py b/pandas/core/arrays/arrow/accessors.py index 3dd3465f2c9eb..aea162461d3c1 100644 --- a/pandas/core/arrays/arrow/accessors.py +++ b/pandas/core/arrays/arrow/accessors.py @@ -97,7 +97,7 @@ def len(self) -> Series: str.len : Python built-in function returning the length of an object. Series.size : Returns the length of the Series. StringMethods.len : Compute the length of each element in the Series/Index. - + Examples -------- >>> import pyarrow as pa @@ -137,7 +137,7 @@ def __getitem__(self, key: int | slice) -> Series: See Also -------- ListAccessor.flatten : Flatten list values. - + Examples -------- >>> import pyarrow as pa diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index 3e94cf09e3ca3..a09dc20af3b36 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -675,7 +675,7 @@ def density(self) -> float: -------- DataFrame.sparse.from_spmatrix : Create a new DataFrame from a scipy sparse matrix. - + Examples -------- >>> from pandas.arrays import SparseArray diff --git a/pandas/core/series.py b/pandas/core/series.py index 749e1dbda7425..ed27984526fa5 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4098,7 +4098,8 @@ def reorder_levels(self, order: Sequence[Level]) -> Series: See Also -------- - DataFrame.reorder_levels : Rearrange index or column levels using input ``order``. + DataFrame.reorder_levels : Rearrange index or column levels using + input ``order``. Examples -------- @@ -5057,7 +5058,7 @@ def pop(self, item: Hashable) -> Any: -------- Series.drop: Drop specified values from Series. Series.drop_duplicates: Return Series with duplicate values removed. - + Examples -------- >>> ser = pd.Series([1, 2, 3])