From 575fd575391c627b73b9a50ed5388435df6d4146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Ramet?= Date: Tue, 18 Apr 2023 13:29:23 +0000 Subject: [PATCH 1/2] added test for issue #32218 --- pandas/tests/frame/test_constructors.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 4815fde4d9d6c..9e18aadb2a38c 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -2639,6 +2639,12 @@ def test_construction_empty_array_multi_column_raises(self): with pytest.raises(ValueError, match=msg): DataFrame(data=np.array([]), columns=["a", "b"]) + def test_construct_with_strings_and_none(self): + # GH#32218 + df = DataFrame(["1", "2", None], columns=["a"], dtype="str") + expected = df = DataFrame({"a": ["1", "2", None]}, dtype="str") + tm.assert_frame_equal(df, expected) + class TestDataFrameConstructorIndexInference: def test_frame_from_dict_of_series_overlapping_monthly_period_indexes(self): From 4129ee9f0f6eb9ae127e68d4bd99763810c8e2ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Ramet?= Date: Tue, 18 Apr 2023 13:31:24 +0000 Subject: [PATCH 2/2] added test for issue #32218 --- pandas/tests/frame/test_constructors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 9e18aadb2a38c..87d78f06b6975 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -2642,7 +2642,7 @@ def test_construction_empty_array_multi_column_raises(self): def test_construct_with_strings_and_none(self): # GH#32218 df = DataFrame(["1", "2", None], columns=["a"], dtype="str") - expected = df = DataFrame({"a": ["1", "2", None]}, dtype="str") + expected = DataFrame({"a": ["1", "2", None]}, dtype="str") tm.assert_frame_equal(df, expected)