Skip to content

Commit d6f646e

Browse files
committed
Fix: Raise exception when errors="coerce" would cause uint64 and NaNs to exist in the same array.
1 parent 7e87385 commit d6f646e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/tools/numeric.py

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ def to_numeric(arg, errors='raise', downcast=None):
135135
except Exception:
136136
if errors == 'raise':
137137
raise
138+
elif errors == 'coerce' and not is_numeric_dtype(values):
139+
raise
138140

139141
# attempt downcast only if the data has been successfully converted
140142
# to a numerical dtype and if a downcast method has been specified

0 commit comments

Comments
 (0)