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

Use more pylibcudf Python enums in cudf._lib #17288

Merged
merged 1 commit into from
Nov 9, 2024
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
7 changes: 2 additions & 5 deletions python/cudf/cudf/_lib/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ from cudf._lib.utils cimport columns_from_pylibcudf_table

from cudf._lib.scalar import as_device_scalar

from pylibcudf.libcudf.replace cimport replace_policy
from pylibcudf.libcudf.scalar.scalar cimport scalar

import pylibcudf
Expand Down Expand Up @@ -244,13 +243,11 @@ cdef class GroupBy:
return columns_from_pylibcudf_table(shifts), columns_from_pylibcudf_table(keys)

def replace_nulls(self, list values, object method):
# TODO: This is using an enum (replace_policy) that has not been exposed in
# pylibcudf yet. We'll want to fix that import once it is in pylibcudf.
_, replaced = self._groupby.replace_nulls(
pylibcudf.table.Table([c.to_pylibcudf(mode="read") for c in values]),
[
replace_policy.PRECEDING
if method == 'ffill' else replace_policy.FOLLOWING
pylibcudf.replace.ReplacePolicy.PRECEDING
if method == 'ffill' else pylibcudf.replace.ReplacePolicy.FOLLOWING
] * len(values),
)

Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/_lib/json.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ cpdef read_json(object filepaths_or_buffers,
)
df = cudf.DataFrame._from_data(
*_data_from_columns(
columns=[Column.from_pylibcudf(plc) for plc in res_cols],
columns=[Column.from_pylibcudf(col) for col in res_cols],
column_names=res_col_names,
index_names=None
)
Expand Down
8 changes: 6 additions & 2 deletions python/cudf/cudf/_lib/lists.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from cudf.core.buffer import acquire_spill_lock

from libcpp cimport bool

from pylibcudf.libcudf.types cimport null_order, size_type
from pylibcudf.libcudf.types cimport size_type

from cudf._lib.column cimport Column
from cudf._lib.utils cimport columns_from_pylibcudf_table
Expand Down Expand Up @@ -49,7 +49,11 @@ def sort_lists(Column col, bool ascending, str na_position):
plc.lists.sort_lists(
col.to_pylibcudf(mode="read"),
ascending,
null_order.BEFORE if na_position == "first" else null_order.AFTER,
(
plc.types.NullOrder.BEFORE
if na_position == "first"
else plc.types.NullOrder.AFTER
),
False,
)
)
Expand Down
Loading