MNT Use is_sparse to validate sparse data from pandas
@@ -807,6 +807,10 @@ def check_array(
# When all dataframe columns are sparse, convert to a sparse array
if hasattr(array, "sparse") and array.ndim > 1:
+ with suppress(ImportError):
+ from pandas.api.types import is_sparse
+
+ if array.dtypes.apply(is_sparse).all():
# DataFrame.sparse only supports `to_coo`
array = array.sparse.to_coo()
if array.dtype == np.dtype("object"):
