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 aee48c9 commit 079c403Copy full SHA for 079c403
pandas/core/dtypes/cast.py
@@ -1919,9 +1919,9 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1919
return element
1920
# GH 57338
1921
# Check boolean array set as object type
1922
- comp = [lib.is_bool(e) for e in np.array([element]).ravel()]
1923
- if all(comp):
1924
- return element.astype("bool")
+ if tipo.kind == "O" and isinstance(element, np.ndarray):
+ if all(lib.is_bool(e) for e in element):
+ return element.astype("bool")
1925
raise LossySetitemError
1926
1927
if lib.is_bool(element):
0 commit comments