pandas.Series.sparse#
- Series.sparse()[source]#
Accessor for SparseSparse from other sparse matrix data types.
- Parameters:
- dataSeries 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])