Skip to content

Commit 3dc68d4

Browse files
Fix failure to convert string "uint64" to NaN
Including regression test
1 parent edb863e commit 3dc68d4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/_libs/lib.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,8 +2024,6 @@ def maybe_convert_numeric(ndarray[object] values, set na_values,
20242024
except (TypeError, ValueError) as err:
20252025
if not seen.coerce_numeric:
20262026
raise type(err)(f"{err} at position {i}")
2027-
elif "uint64" in str(err): # Exception from check functions.
2028-
raise
20292027

20302028
seen.saw_null()
20312029
floats[i] = NaN

pandas/tests/dtypes/test_inference.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,13 @@ def test_convert_numeric_int64_uint64(self, case, coerce):
507507
result = lib.maybe_convert_numeric(case, set(), coerce_numeric=coerce)
508508
tm.assert_almost_equal(result, expected)
509509

510+
def test_convert_numeric_string_uint64(self):
511+
# GH32394
512+
result = lib.maybe_convert_numeric(
513+
np.array(["uint64"], dtype=object), set(), coerce_numeric=True
514+
)
515+
assert np.isnan(result)
516+
510517
@pytest.mark.parametrize("value", [-(2 ** 63) - 1, 2 ** 64])
511518
def test_convert_int_overflow(self, value):
512519
# see gh-18584

0 commit comments

Comments
 (0)