Skip to content

Commit 42fe69c

Browse files
author
Rajat Jain
committed
BUG: Fixed bug to convert a ndarray to dtype int32
1 parent 34177d6 commit 42fe69c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/dtypes/cast.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,8 @@ def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.n
16971697
)
16981698
raise ValueError("Trying to coerce float values to integers")
16991699
if arr.dtype == object:
1700+
if (casted.astype(str) == arr).all():
1701+
return casted
17001702
raise ValueError("Trying to coerce object values to integers")
17011703

17021704
if casted.dtype < arr.dtype:

0 commit comments

Comments
 (0)