Skip to content

Commit 14daddf

Browse files
committed
using lib is_bool to check for bool
1 parent 592fc5d commit 14daddf

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

pandas/core/dtypes/cast.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,14 +1920,9 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
19201920
return element
19211921
# GH 57338
19221922
# Check boolean array set as object type
1923-
with np.errstate(invalid="ignore"):
1924-
casted = element.astype(dtype)
1925-
comp = [
1926-
i is j
1927-
for i, j in zip(element.astype("object"), casted.astype("object"))
1928-
]
1923+
comp = [lib.is_bool(e) for e in element]
19291924
if all(comp):
1930-
return casted
1925+
return element.astype("bool")
19311926
raise LossySetitemError
19321927

19331928
if lib.is_bool(element):

0 commit comments

Comments
 (0)