From 136e9f824ab9fb8544d59b89d12651dcdeb5bb1a Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Thu, 19 Nov 2020 22:55:50 -0500 Subject: [PATCH 1/2] TST: add nullable array constructor dtype tests --- pandas/tests/frame/test_constructors.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 951a462bad3e3..c6f8d06b3bb87 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -1004,6 +1004,20 @@ def test_constructor_dtype(self, data, index, columns, dtype, expected): df = DataFrame(data, index, columns, dtype) assert df.values.dtype == expected + @pytest.mark.parametrize( + "data,input_dtype,expected_dtype", + ( + ([True, False, None], "boolean", pd.BooleanDtype), + ([1.0, 2.0, None], "Float64", pd.Float64Dtype), + ([1, 2, None], "Int64", pd.Int64Dtype), + ), + ) + def test_constructor_dtype_nullable_extension_arrays( + self, data, input_dtype, expected_dtype + ): + df = DataFrame({"a": data}, dtype=input_dtype) + assert df["a"].dtype == expected_dtype() + def test_constructor_scalar_inference(self): data = {"int": 1, "bool": True, "float": 3.0, "complex": 4j, "object": "foo"} df = DataFrame(data, index=np.arange(10)) From a3db81ed9492fe13fec2b455f24ae672f299b6bb Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 20 Nov 2020 12:42:25 -0500 Subject: [PATCH 2/2] TST (feedback): add string example --- pandas/tests/frame/test_constructors.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index c6f8d06b3bb87..27c12aa4fb3d1 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -1010,6 +1010,7 @@ def test_constructor_dtype(self, data, index, columns, dtype, expected): ([True, False, None], "boolean", pd.BooleanDtype), ([1.0, 2.0, None], "Float64", pd.Float64Dtype), ([1, 2, None], "Int64", pd.Int64Dtype), + (["a", "b", "c"], "string", pd.StringDtype), ), ) def test_constructor_dtype_nullable_extension_arrays(