Skip to content

Commit 6454943

Browse files
authored
TST: add nullable array frame constructor dtype tests (#37972)
1 parent b617bee commit 6454943

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/frame/test_constructors.py

+15
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,21 @@ 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+
(["a", "b", "c"], "string", pd.StringDtype),
1014+
),
1015+
)
1016+
def test_constructor_dtype_nullable_extension_arrays(
1017+
self, data, input_dtype, expected_dtype
1018+
):
1019+
df = DataFrame({"a": data}, dtype=input_dtype)
1020+
assert df["a"].dtype == expected_dtype()
1021+
10071022
def test_constructor_scalar_inference(self):
10081023
data = {"int": 1, "bool": True, "float": 3.0, "complex": 4j, "object": "foo"}
10091024
df = DataFrame(data, index=np.arange(10))

0 commit comments

Comments
 (0)