Skip to content

Commit

Permalink
DOCS: fix docstring validation errors for pandas.Series
Browse files Browse the repository at this point in the history
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" \
  • Loading branch information
ivonastojanovic committed Aug 24, 2024
1 parent 224c6ff commit cbb40d8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
4 changes: 0 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-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" \
-i "pandas.Series.sparse.sp_values SA01" \
-i "pandas.Series.sparse.to_coo PR07,RT03,SA01" \
-i "pandas.Series.std PR01,RT03,SA01" \
-i "pandas.Series.str.match RT03" \
Expand Down
12 changes: 12 additions & 0 deletions pandas/core/arrays/sparse/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def from_coo(cls, A, dense_index: bool = False) -> Series:
Parameters
----------
A : scipy.sparse.coo_matrix
A sparse matrix in COOrdinate format. The matrix should have
non-zero elements that will be used to create a Series with sparse
values. The row and column indices of these elements form the index
of the Series.
dense_index : bool, default False
If False (default), the index consists of only the
coords of the non-null entries of the original coo_matrix.
Expand All @@ -90,6 +94,14 @@ def from_coo(cls, A, dense_index: bool = False) -> Series:
s : Series
A Series with sparse values.
See Also
--------
scipy.sparse.coo_matrix : Sparse matrix in COOrdinate format.
pd.Series.sparse : Accessor object for sparse data in a Series.
pd.DataFrame.sparse.from_spmatrix : Create a DataFrame with sparse
values from a scipy sparse matrix.
pd.SparseArray : Array type for storing sparse data.
Examples
--------
>>> from scipy import sparse
Expand Down
20 changes: 20 additions & 0 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,15 @@ def sp_values(self) -> np.ndarray:
"""
An ndarray containing the non- ``fill_value`` values.
See Also
--------
SparseArray : Array type for storing sparse data.
SparseArray.sp_index : The index object storing the positions of
non-``fill_value`` values.
SparseArray.fill_value : The value considered as "missing" or not stored.
SparseArray.sp_values : Returns the non-``fill_value`` values in the sparse
array.
Examples
--------
>>> from pandas.arrays import SparseArray
Expand All @@ -623,6 +632,11 @@ def fill_value(self):
For memory savings, this should be the most common value in the array.
See Also
--------
pd.SparseDtype : Type for sparse data which holds the dtype and fill_value.
pd.Series.sparse : Accessor object for sparse data in a Series.
Examples
--------
>>> ser = pd.Series([0, 0, 2, 2, 2], dtype="Sparse[int]")
Expand Down Expand Up @@ -685,6 +699,12 @@ def npoints(self) -> int:
"""
The number of non- ``fill_value`` points.
See Also
--------
SparseArray : Array type for storing sparse data.
SparseIndex : Stores the locations and counts of non-``fill_value`` data.
SparseArray.fill_value : The value considered as "missing" or not stored.
Examples
--------
>>> from pandas.arrays import SparseArray
Expand Down

0 comments on commit cbb40d8

Please sign in to comment.