Skip to main content
`Ctrl`+`K`

# pandas.Series.sparse

Series.sparse()

  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]")
      >>> ser.sparse.density
      0.6
      >>> ser.sparse.sp_values
      array([2, 2, 2])