Skip to content

Commit

Permalink
DOC: fix docstring validation errors for pandas.Series (#59633)
Browse files Browse the repository at this point in the history
* fixed Series.sparse and Series.sparse.to_coo and removed from ci/code_checks.sh

* fixed errors from pre-commit

* fixed errors from pre-commit
  • Loading branch information
pol-rius authored Aug 28, 2024
1 parent eb05b13 commit ef3368a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 0 additions & 2 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Series.dt.tz_localize PR01,PR02" \
-i "pandas.Series.dt.unit GL08" \
-i "pandas.Series.pad PR01,SA01" \
-i "pandas.Series.sparse PR01,SA01" \
-i "pandas.Series.sparse.fill_value SA01" \
-i "pandas.Series.sparse.from_coo PR07,SA01" \
-i "pandas.Series.sparse.npoints SA01" \
-i "pandas.Series.sparse.sp_values SA01" \
-i "pandas.Series.sparse.to_coo PR07,RT03,SA01" \
-i "pandas.Timedelta.asm8 SA01" \
-i "pandas.Timedelta.ceil SA01" \
-i "pandas.Timedelta.components SA01" \
Expand Down
22 changes: 22 additions & 0 deletions pandas/core/arrays/sparse/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ class SparseAccessor(BaseAccessor, PandasDelegate):
"""
Accessor for SparseSparse from other sparse matrix data types.
Parameters
----------
data : Series or DataFrame
The Series or DataFrame to which the SparseAccessor is attached.
See Also
--------
Series.sparse.to_coo : Create a scipy.sparse.coo_matrix from a Series with
MultiIndex.
Series.sparse.from_coo : Create a Series with sparse values from a
scipy.sparse.coo_matrix.
Examples
--------
>>> ser = pd.Series([0, 0, 2, 2, 2], dtype="Sparse[int]")
Expand Down Expand Up @@ -135,7 +147,9 @@ def to_coo(
Parameters
----------
row_levels : tuple/list
MultiIndex levels to use for row coordinates, specified by name or index.
column_levels : tuple/list
MultiIndex levels to use for column coordinates, specified by name or index.
sort_labels : bool, default False
Sort the row and column labels before forming the sparse matrix.
When `row_levels` and/or `column_levels` refer to a single level,
Expand All @@ -144,8 +158,16 @@ def to_coo(
Returns
-------
y : scipy.sparse.coo_matrix
The sparse matrix in coordinate format.
rows : list (row labels)
Labels corresponding to the row coordinates.
columns : list (column labels)
Labels corresponding to the column coordinates.
See Also
--------
Series.sparse.from_coo : Create a Series with sparse values from a
scipy.sparse.coo_matrix.
Examples
--------
Expand Down

0 comments on commit ef3368a

Please sign in to comment.