diff --git a/ci/code_checks.sh b/ci/code_checks.sh index e9f4ee1f391a2..a9e859209ad24 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -147,11 +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" \ -i "pandas.Series.str.normalize RT03,SA01" \ diff --git a/pandas/core/arrays/sparse/accessor.py b/pandas/core/arrays/sparse/accessor.py index b8245349a4e62..5bfb26f02fb51 100644 --- a/pandas/core/arrays/sparse/accessor.py +++ b/pandas/core/arrays/sparse/accessor.py @@ -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. @@ -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 @@ -135,7 +147,13 @@ def to_coo( Parameters ---------- row_levels : tuple/list + The levels of the MultiIndex to use for the row coordinates in the + resulting sparse matrix. These can be specified as the names or + numerical positions of the levels. column_levels : tuple/list + The levels of the MultiIndex to use for the column coordinates in the + resulting sparse matrix. These can be specified as the names or + numerical positions of the levels. 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, @@ -144,8 +162,22 @@ def to_coo( Returns ------- y : scipy.sparse.coo_matrix + A sparse matrix in COOrdinate format representing the non-NA values + of the Series. rows : list (row labels) + The row labels corresponding to the row coordinates in the sparse matrix. columns : list (column labels) + The column labels corresponding to the column coordinates in the sparse + matrix. + + See Also + -------- + scipy.sparse.coo_matrix : Sparse matrix in COOrdinate format. + pd.Series.sparse.from_coo : Create a Series with sparse values from a + scipy.sparse.coo_matrix. + 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 -------- diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index 3a08344369822..7596469ad60cb 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -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 @@ -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]") @@ -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