Skip to content

Commit

Permalink
GH-35329: [Python] Address pandas.types.is_sparse deprecation (#35366)
Browse files Browse the repository at this point in the history
### Rationale for this change

pandas is deprecating `pandas.types.is_sparse` in 2.1

### What changes are included in this PR?

Changing usages of `is_sparse` to the recommended migration `isinstance(dtype, pd.SparseDtype)`

### Are these changes tested?

### Are there any user-facing changes?

No

closes #35329
* Closes: #35329

Authored-by: Matthew Roeschke <[email protected]>
Signed-off-by: Alenka Frim <[email protected]>
  • Loading branch information
mroeschke authored May 9, 2023
1 parent b73ddc3 commit de6c3cd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/pyarrow/pandas-shim.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ cdef class _PandasAPIShim(object):

cpdef is_sparse(self, obj):
if self._have_pandas_internal():
return self._types_api.is_sparse(obj)
return isinstance(obj.dtype, self.pd.SparseDtype)
else:
return False

Expand Down

0 comments on commit de6c3cd

Please sign in to comment.