pandas.Series.sparse.npoints#
- Series.sparse.npoints[source]#
The number of non-
fill_valuepoints.This property returns the number of elements in the sparse series that are not equal to the
fill_value. Sparse data structures store only the non-fill_valueelements, reducing memory usage when the majority of values are the same.See also
Series.sparse.to_denseConvert a Series from sparse values to dense.
Series.sparse.fill_valueElements in
datathat arefill_valueare not stored.Series.sparse.densityThe percent of non-
fill_valuepoints, as decimal.
Examples
>>> from pandas.arrays import SparseArray >>> s = SparseArray([0, 0, 1, 1, 1], fill_value=0) >>> s.npoints 3