pandas.DataFrame.sparse.density#

DataFrame.sparse.density[source]#

Ratio of non-sparse points to total (dense) data points.

See also

DataFrame.sparse.from_spmatrix

Create a new DataFrame from a scipy sparse matrix.

Examples

>>> df = pd.DataFrame({"A": pd.arrays.SparseArray([0, 1, 0, 1])})
>>> df.sparse.density
0.5