We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 592fc5d commit 14daddfCopy full SHA for 14daddf
pandas/core/dtypes/cast.py
@@ -1920,14 +1920,9 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1920
return element
1921
# GH 57338
1922
# 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
- ]
+ comp = [lib.is_bool(e) for e in element]
1929
if all(comp):
1930
- return casted
+ return element.astype("bool")
1931
raise LossySetitemError
1932
1933
if lib.is_bool(element):
0 commit comments