From 698f064c363de6eb286f4fb45153540a74fc05c2 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 2 Sep 2022 11:49:08 -0700 Subject: [PATCH] TST: to_numeric(large_float, downcast=float) isn't lossy --- pandas/tests/tools/test_to_numeric.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/tests/tools/test_to_numeric.py b/pandas/tests/tools/test_to_numeric.py index 38a50a10b3482..1347f6eb50b09 100644 --- a/pandas/tests/tools/test_to_numeric.py +++ b/pandas/tests/tools/test_to_numeric.py @@ -799,3 +799,11 @@ def test_to_numeric_scientific_notation(): result = to_numeric("1.7e+308") expected = np.float64(1.7e308) assert result == expected + + +@pytest.mark.parametrize("val", [9876543210.0, 2.0**128]) +def test_to_numeric_large_float_not_downcast_to_float_32(val): + # GH 19729 + expected = Series([val]) + result = to_numeric(expected, downcast="float") + tm.assert_series_equal(result, expected)