Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.api.types.is_sparse#

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

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

Deprecated since version 2.1.0:Use isinstance(dtype, pd.SparseDtype) instead.

Check that the one-dimensional array-like is a pandas sparse array.Returns True if it is a pandas sparse array, not another type ofsparse array.

Parameters:
arrarray-like

Array-like to check.

Returns:
bool

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

Examples

ReturnsTrue if the parameter is a 1-D pandas sparse array.

>>>frompandas.api.typesimportis_sparse>>>is_sparse(pd.arrays.SparseArray([0,0,1,0]))True>>>is_sparse(pd.Series(pd.arrays.SparseArray([0,0,1,0])))True

ReturnsFalse if the parameter is not sparse.

>>>is_sparse(np.array([0,0,1,0]))False>>>is_sparse(pd.Series([0,1,0,0]))False

ReturnsFalse if the parameter is not a pandas sparse array.

>>>fromscipy.sparseimportbsr_matrix>>>is_sparse(bsr_matrix([0,1,0,0]))False

ReturnsFalse if the parameter has more than one dimension.


[8]ページ先頭

©2009-2025 Movatter.jp