diff --git a/python/cudf/cudf/core/column/column.py b/python/cudf/cudf/core/column/column.py index 5f9104263b1..6f2f01c746d 100644 --- a/python/cudf/cudf/core/column/column.py +++ b/python/cudf/cudf/core/column/column.py @@ -2060,6 +2060,11 @@ def as_column( return cudf.core.column.Decimal32Column.from_arrow( data ) + if is_bool_dtype(dtype): + # Need this special case handling for bool dtypes, + # since 'boolean' & 'pd.BooleanDtype' are not + # understood by np.dtype below. + dtype = "bool" np_type = np.dtype(dtype).type pa_type = np_to_pa_dtype(np.dtype(dtype)) data = as_column( diff --git a/python/cudf/cudf/tests/test_series.py b/python/cudf/cudf/tests/test_series.py index 09f0417b7ac..73fe46746ce 100644 --- a/python/cudf/cudf/tests/test_series.py +++ b/python/cudf/cudf/tests/test_series.py @@ -1335,3 +1335,14 @@ def test_equals_names(lhs, rhs): expect = lhs.to_pandas().equals(rhs.to_pandas()) assert_eq(expect, got) + + +@pytest.mark.parametrize( + "data", [[True, False, None, True, False], [None, None], []] +) +@pytest.mark.parametrize("bool_dtype", ["bool", "boolean", pd.BooleanDtype()]) +def test_nullable_bool_dtype_series(data, bool_dtype): + psr = pd.Series(data, dtype=pd.BooleanDtype()) + gsr = cudf.Series(data, dtype=bool_dtype) + + assert_eq(psr, gsr.to_pandas(nullable=True))