diff --git a/python/cudf/cudf/core/column/column.py b/python/cudf/cudf/core/column/column.py index f13d8cf12f7..6103bbfc971 100644 --- a/python/cudf/cudf/core/column/column.py +++ b/python/cudf/cudf/core/column/column.py @@ -2009,7 +2009,7 @@ def as_column( length = 1 elif length < 0: raise ValueError(f"{length=} must be >=0.") - if isinstance(arbitrary, pd.Interval): + if isinstance(arbitrary, pd.Interval) or _is_categorical_dtype(dtype): # No cudf.Scalar support yet return as_column( pd.Series([arbitrary] * length), diff --git a/python/cudf/cudf/tests/test_categorical.py b/python/cudf/cudf/tests/test_categorical.py index ad32ebce01b..cc3e20b5bac 100644 --- a/python/cudf/cudf/tests/test_categorical.py +++ b/python/cudf/cudf/tests/test_categorical.py @@ -846,3 +846,11 @@ def test_empty_series_category_cast(ordered): assert_eq(expected, actual) assert_eq(expected.dtype.ordered, actual.dtype.ordered) + + +@pytest.mark.parametrize("scalar", [1, "a", None, 10.2]) +def test_cat_from_scalar(scalar): + ps = pd.Series(scalar, dtype="category") + gs = cudf.Series(scalar, dtype="category") + + assert_eq(ps, gs)