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

Consolidate cudf object handling in as_column #14754

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Changes from 3 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
21 changes: 9 additions & 12 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -1911,20 +1911,17 @@ def as_column(
if dtype is not None:
column = column.astype(dtype)
return column
elif isinstance(arbitrary, ColumnBase):
if dtype is not None:
return arbitrary.astype(dtype)
elif isinstance(arbitrary, (ColumnBase, cudf.Series, cudf.BaseIndex)):
if isinstance(arbitrary, cudf.Series):
column = arbitrary._column
elif isinstance(arbitrary, cudf.BaseIndex):
column = arbitrary._values
else:
return arbitrary
elif isinstance(arbitrary, cudf.Series):
data = arbitrary._column
if dtype is not None:
data = data.astype(dtype)
elif isinstance(arbitrary, cudf.BaseIndex):
data = arbitrary._values
column = arbitrary
vyasr marked this conversation as resolved.
Show resolved Hide resolved
# TODO: Should nan_as_null apply here?
vyasr marked this conversation as resolved.
Show resolved Hide resolved
if dtype is not None:
data = data.astype(dtype)

column = column.astype(dtype)
vyasr marked this conversation as resolved.
Show resolved Hide resolved
return column
elif hasattr(arbitrary, "__cuda_array_interface__"):
desc = arbitrary.__cuda_array_interface__
shape = desc["shape"]
Expand Down