Skip to content

Commit f431efc

Browse files
committed
full check for casting to boolean
1 parent 5dba4cc commit f431efc

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

pandas/core/dtypes/cast.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,14 +1918,11 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
19181918
# i.e. there are pd.NA elements
19191919
raise LossySetitemError
19201920
return element
1921+
# GH 57338
19211922
with np.errstate(invalid="ignore"):
1922-
# We check afterwards if cast was losslessly, so no need to show
1923-
# the warning
19241923
casted = element.astype(dtype)
19251924
comp = casted == element
19261925
if comp.all():
1927-
# Return the casted values bc they can be passed to
1928-
# np.putmask, whereas the raw values cannot.
19291926
return casted
19301927
raise LossySetitemError
19311928

0 commit comments

Comments
 (0)