Skip to content

Commit 1d0ffc0

Browse files
committed
TST: add nullable array constructor dtype tests
1 parent b2b81d8 commit 1d0ffc0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/frame/test_constructors.py

+14
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,20 @@ def test_constructor_dtype(self, data, index, columns, dtype, expected):
10041004
df = DataFrame(data, index, columns, dtype)
10051005
assert df.values.dtype == expected
10061006

1007+
@pytest.mark.parametrize(
1008+
"data,input_dtype,expected_dtype",
1009+
(
1010+
([True, False, None], "boolean", pd.BooleanDtype),
1011+
([1.0, 2.0, None], "Float64", pd.Float64Dtype),
1012+
([1, 2, None], "Int64", pd.Int64Dtype),
1013+
),
1014+
)
1015+
def test_constructor_dtype_nullable_extension_arrays(
1016+
self, data, input_dtype, expected_dtype
1017+
):
1018+
df = DataFrame({"a": data}, dtype=input_dtype)
1019+
assert df["a"].dtype == expected_dtype()
1020+
10071021
def test_constructor_scalar_inference(self):
10081022
data = {"int": 1, "bool": True, "float": 3.0, "complex": 4j, "object": "foo"}
10091023
df = DataFrame(data, index=np.arange(10))

0 commit comments

Comments
 (0)