Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise error when mixed types are being constructed #13816

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -2161,9 +2161,7 @@ def as_column(
if dtype is not None:
data = data.astype(dtype)
elif arb_dtype.kind in ("O", "U"):
data = as_column(
pa.Array.from_pandas(arbitrary), dtype=arbitrary.dtype
)
data = as_column(pa.array(arbitrary), dtype=arbitrary.dtype)
# There is no cast operation available for pa.Array from int to
# str, Hence instead of handling in pa.Array block, we
# will have to type-cast here.
Expand Down Expand Up @@ -2422,7 +2420,7 @@ def _construct_array(
if (
dtype is None
and not cudf._lib.scalar._is_null_host_scalar(arbitrary)
and infer_dtype(arbitrary)
and infer_dtype(arbitrary, skipna=False)
in (
"mixed",
"mixed-integer",
Expand Down
5 changes: 5 additions & 0 deletions python/cudf/cudf/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2219,3 +2219,8 @@ def __getitem__(self, key):

with pytest.raises(TypeError):
cudf.Series(A())


def test_series_constructor_error_mixed_type():
with pytest.raises(pa.ArrowTypeError):
cudf.Series(["abc", np.nan, "123"], nan_as_null=False)