Skip to content

DOCS: fix docstring validation errors for pandas.Series #59602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 25, 2024
11 changes: 0 additions & 11 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,9 @@ 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.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" \
-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" \
-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" \
Expand Down
14 changes: 14 additions & 0 deletions pandas/core/arrays/arrow/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
"""
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/ops/docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand Down
13 changes: 12 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4093,7 +4093,13 @@ 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
--------
Expand Down Expand Up @@ -5048,6 +5054,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])
Expand Down