Skip to content

Commit dad8f56

Browse files
DOCS: fix docstring validation errors for pandas.Series.sparse
Fixes: -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" \
1 parent 224c6ff commit dad8f56

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

ci/code_checks.sh

-4
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
147147
-i "pandas.Series.sem PR01,RT03,SA01" \
148148
-i "pandas.Series.sparse PR01,SA01" \
149149
-i "pandas.Series.sparse.density SA01" \
150-
-i "pandas.Series.sparse.fill_value SA01" \
151-
-i "pandas.Series.sparse.from_coo PR07,SA01" \
152-
-i "pandas.Series.sparse.npoints SA01" \
153-
-i "pandas.Series.sparse.sp_values SA01" \
154150
-i "pandas.Series.sparse.to_coo PR07,RT03,SA01" \
155151
-i "pandas.Series.std PR01,RT03,SA01" \
156152
-i "pandas.Series.str.match RT03" \

pandas/core/arrays/sparse/accessor.py

+32
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def from_coo(cls, A, dense_index: bool = False) -> Series:
7979
Parameters
8080
----------
8181
A : scipy.sparse.coo_matrix
82+
A sparse matrix in COOrdinate format. The matrix should have
83+
non-zero elements that will be used to create a Series with sparse
84+
values. The row and column indices of these elements form the index
85+
of the Series.
8286
dense_index : bool, default False
8387
If False (default), the index consists of only the
8488
coords of the non-null entries of the original coo_matrix.
@@ -90,6 +94,14 @@ def from_coo(cls, A, dense_index: bool = False) -> Series:
9094
s : Series
9195
A Series with sparse values.
9296
97+
See Also
98+
--------
99+
scipy.sparse.coo_matrix : Sparse matrix in COOrdinate format.
100+
pd.Series.sparse : Accessor object for sparse data in a Series.
101+
pd.DataFrame.sparse.from_spmatrix : Create a DataFrame with sparse
102+
values from a scipy sparse matrix.
103+
pd.SparseArray : Array type for storing sparse data.
104+
93105
Examples
94106
--------
95107
>>> from scipy import sparse
@@ -135,7 +147,13 @@ def to_coo(
135147
Parameters
136148
----------
137149
row_levels : tuple/list
150+
The levels of the MultiIndex to use for the row coordinates in the
151+
resulting sparse matrix. These can be specified as the names or
152+
numerical positions of the levels.
138153
column_levels : tuple/list
154+
The levels of the MultiIndex to use for the column coordinates in the
155+
resulting sparse matrix. These can be specified as the names or
156+
numerical positions of the levels.
139157
sort_labels : bool, default False
140158
Sort the row and column labels before forming the sparse matrix.
141159
When `row_levels` and/or `column_levels` refer to a single level,
@@ -144,8 +162,22 @@ def to_coo(
144162
Returns
145163
-------
146164
y : scipy.sparse.coo_matrix
165+
A sparse matrix in COOrdinate format representing the non-NA values
166+
of the Series.
147167
rows : list (row labels)
168+
The row labels corresponding to the row coordinates in the sparse matrix.
148169
columns : list (column labels)
170+
The column labels corresponding to the column coordinates in the sparse
171+
matrix.
172+
173+
See Also
174+
--------
175+
scipy.sparse.coo_matrix : Sparse matrix in COOrdinate format.
176+
pd.Series.sparse.from_coo : Create a Series with sparse values from a
177+
scipy.sparse.coo_matrix.
178+
pd.DataFrame.sparse.from_spmatrix : Create a DataFrame with sparse values
179+
from a scipy sparse matrix.
180+
pd.SparseArray : Array type for storing sparse data.
149181
150182
Examples
151183
--------

pandas/core/arrays/sparse/array.py

+20
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,15 @@ def sp_values(self) -> np.ndarray:
603603
"""
604604
An ndarray containing the non- ``fill_value`` values.
605605
606+
See Also
607+
--------
608+
SparseArray : Array type for storing sparse data.
609+
SparseArray.sp_index : The index object storing the positions of
610+
non-``fill_value`` values.
611+
SparseArray.fill_value : The value considered as "missing" or not stored.
612+
SparseArray.sp_values : Returns the non-``fill_value`` values in the sparse
613+
array.
614+
606615
Examples
607616
--------
608617
>>> from pandas.arrays import SparseArray
@@ -623,6 +632,11 @@ def fill_value(self):
623632
624633
For memory savings, this should be the most common value in the array.
625634
635+
See Also
636+
--------
637+
pd.SparseDtype : Type for sparse data which holds the dtype and fill_value.
638+
pd.Series.sparse : Accessor object for sparse data in a Series.
639+
626640
Examples
627641
--------
628642
>>> ser = pd.Series([0, 0, 2, 2, 2], dtype="Sparse[int]")
@@ -685,6 +699,12 @@ def npoints(self) -> int:
685699
"""
686700
The number of non- ``fill_value`` points.
687701
702+
See Also
703+
--------
704+
SparseArray : Array type for storing sparse data.
705+
SparseIndex : Stores the locations and counts of non-``fill_value`` data.
706+
SparseArray.fill_value : The value considered as "missing" or not stored.
707+
688708
Examples
689709
--------
690710
>>> from pandas.arrays import SparseArray

0 commit comments

Comments
 (0)