# pandas.SparseDataFrame.to_coo¶

SparseDataFrame.to_coo()[source]

Return the contents of the frame as a sparse SciPy COO matrix.

New in version 0.20.0.

Returns: coo_matrix : scipy.sparse.spmatrix If the caller is heterogeneous and contains booleans or objects, the result will be of dtype=object. See Notes.

Notes

The dtype will be the lowest-common-denominator type (implicit upcasting); that is to say if the dtypes (even of numeric types) are mixed, the one that accommodates all will be chosen.

e.g. If the dtypes are float16 and float32, dtype will be upcast to float32. By numpy.find_common_type convention, mixing int64 and and uint64 will result in a float64 dtype.

Scroll To Top