pandas.api.types.is_sparse

pandas.api.types.is_sparse(arr) [source]

Check whether an array-like is a pandas sparse array.

Parameters:

arr : array-like

The array-like to check.

Returns:
boolean : Whether or not the array-like is a pandas sparse array.

Examples

>>> is_sparse(np.array([1, 2, 3]))
False
>>> is_sparse(pd.SparseArray([1, 2, 3]))
True
>>> is_sparse(pd.SparseSeries([1, 2, 3]))
True

This function checks only for pandas sparse array instances, so sparse arrays from other libraries will return False.

>>> from scipy.sparse import bsr_matrix
>>> is_sparse(bsr_matrix([1, 2, 3]))
False

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.api.types.is_sparse.html