Skip to content

Commit

Permalink
Merge branch 'branch-24.06' into pandas/tests/user_agent
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar authored Apr 8, 2024
2 parents b338688 + 6c31eac commit 3f70071
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,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),
Expand Down
8 changes: 8 additions & 0 deletions python/cudf/cudf/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 3f70071

Please sign in to comment.