diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 72678be1587f8..0d1c362a87f12 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -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" \ diff --git a/pandas/core/arrays/sparse/accessor.py b/pandas/core/arrays/sparse/accessor.py index b8245349a4e62..e610e018c5a74 100644 --- a/pandas/core/arrays/sparse/accessor.py +++ b/pandas/core/arrays/sparse/accessor.py @@ -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]") @@ -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, @@ -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 --------