From bfabeeb7930eb06e4e967dec05cb54097bd2253b Mon Sep 17 00:00:00 2001 From: Steven Rotondo Date: Mon, 22 Aug 2022 17:01:09 -0700 Subject: [PATCH 1/2] TST: Wrote test for Float64 conversion #40729 --- pandas/tests/dtypes/test_dtypes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index 64849c4223486..10ff61acc5eae 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -37,6 +37,7 @@ date_range, ) import pandas._testing as tm +from pandas.core.arrays.floating import Float64Dtype from pandas.core.arrays.sparse import ( SparseArray, SparseDtype, @@ -1152,3 +1153,13 @@ def test_multi_column_dtype_assignment(): df["b"] = 0 tm.assert_frame_equal(df, expected) + + +def test_Float64_conversion(): + # GH#40729 + testseries = Series(["1", "2", "3", "4"], dtype="object") + result = testseries.astype(Float64Dtype()) + + expected = Series([1.0, 2.0, 3.0, 4.0], dtype=Float64Dtype()) + + tm.assert_series_equal(result, expected) From 079b5c938480568260fa7856da7314e331518716 Mon Sep 17 00:00:00 2001 From: Steven Rotondo Date: Tue, 23 Aug 2022 14:46:39 -0700 Subject: [PATCH 2/2] TST: Moved test #40729 --- pandas/tests/arrays/floating/test_astype.py | 10 ++++++++++ pandas/tests/dtypes/test_dtypes.py | 11 ----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pandas/tests/arrays/floating/test_astype.py b/pandas/tests/arrays/floating/test_astype.py index 8f61f70fe0735..5a6e0988a0897 100644 --- a/pandas/tests/arrays/floating/test_astype.py +++ b/pandas/tests/arrays/floating/test_astype.py @@ -116,3 +116,13 @@ def test_astype_object(dtype): # check exact element types assert isinstance(result[0], float) assert result[1] is pd.NA + + +def test_Float64_conversion(): + # GH#40729 + testseries = pd.Series(["1", "2", "3", "4"], dtype="object") + result = testseries.astype(pd.Float64Dtype()) + + expected = pd.Series([1.0, 2.0, 3.0, 4.0], dtype=pd.Float64Dtype()) + + tm.assert_series_equal(result, expected) diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index 10ff61acc5eae..64849c4223486 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -37,7 +37,6 @@ date_range, ) import pandas._testing as tm -from pandas.core.arrays.floating import Float64Dtype from pandas.core.arrays.sparse import ( SparseArray, SparseDtype, @@ -1153,13 +1152,3 @@ def test_multi_column_dtype_assignment(): df["b"] = 0 tm.assert_frame_equal(df, expected) - - -def test_Float64_conversion(): - # GH#40729 - testseries = Series(["1", "2", "3", "4"], dtype="object") - result = testseries.astype(Float64Dtype()) - - expected = Series([1.0, 2.0, 3.0, 4.0], dtype=Float64Dtype()) - - tm.assert_series_equal(result, expected)