Skip to content

Commit 504be90

Browse files
author
Daniel Saxton
committed
Use isfinite
1 parent ffed8a0 commit 504be90

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pandas/core/arrays/categorical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def astype(self, dtype: Dtype, copy: bool = True) -> ArrayLike:
520520
if dtype == self.dtype:
521521
return self
522522
return self._set_dtype(dtype)
523-
if is_integer_dtype(dtype) and self.isin([np.nan, -np.inf, np.inf]).any():
523+
if is_integer_dtype(dtype) and np.isfinite(self.__array__()).all():
524524
msg = "Cannot cast to int."
525525
raise ValueError(msg)
526526
return np.array(self, dtype=dtype, copy=copy)

0 commit comments

Comments
 (0)