Skip to main content
`Ctrl`+`K`

# pandas.Series.sparse.density

Series.sparse.density

  The percent of non- `fill_value` points, as decimal.

  This is calculated as the number of non-fill-value points divided by the total length of the array. A density of 1.0 means no values are the fill value, while 0.0 means all values are the fill value.

  See also

  `DataFrame.sparse.from_spmatrix`

    Create a new DataFrame from a scipy sparse matrix.

  Examples

      >>> from pandas.arrays import SparseArray
      >>> s = SparseArray([0, 0, 1, 1, 1], fill_value=0)
      >>> s.density
      0.6