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 5dba4cc commit f431efcCopy full SHA for f431efc
pandas/core/dtypes/cast.py
@@ -1918,14 +1918,11 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1918
# i.e. there are pd.NA elements
1919
raise LossySetitemError
1920
return element
1921
+ # GH 57338
1922
with np.errstate(invalid="ignore"):
- # We check afterwards if cast was losslessly, so no need to show
1923
- # the warning
1924
casted = element.astype(dtype)
1925
comp = casted == element
1926
if comp.all():
1927
- # Return the casted values bc they can be passed to
1928
- # np.putmask, whereas the raw values cannot.
1929
return casted
1930
1931
0 commit comments