Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 12 additions & 0 deletions python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ def deserialize(cls, header, frames):
)
return cls._from_data(col_accessor)

@_performance_tracking
def nans_to_nulls(self):
result = []
for col in self._columns:
converted = col.nans_to_nulls()
if converted is col:
converted = converted.copy()
result.append(converted)
return self._from_data_like_self(
self._data._from_columns_like_self(result)
)

@classmethod
@_performance_tracking
def _from_data(cls, data: MutableMapping) -> Self:
Expand Down
10 changes: 1 addition & 9 deletions python/cudf/cudf/core/indexed_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,15 +1935,7 @@ def nans_to_nulls(self):
1 <NA> 3.14
2 <NA> <NA>
"""
result = []
for col in self._columns:
converted = col.nans_to_nulls()
if converted is col:
converted = converted.copy()
result.append(converted)
return self._from_data_like_self(
self._data._from_columns_like_self(result)
)
return super().nans_to_nulls()

@_performance_tracking
def interpolate(
Expand Down
14 changes: 14 additions & 0 deletions python/cudf/cudf/tests/dataframe/methods/test_sort_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,17 @@ def test_dataframe_loc_duplicate_index_scalar():
gdf_sorted = gdf.sort_values(by=list(gdf.columns), axis=0)

assert_eq(pdf_sorted, gdf_sorted)


def test_dataframe_sort_values_multindex():
df = cudf.DataFrame(
{"a": [2, 1, 2, 1], "b": [1, 2, 1, 2], "c": [4, 3, 2, 1]}
)
df = df.set_index(["a", "b"])
pdf = df.to_pandas()

expected = pdf.sort_values(by="a", ascending=True)
with cudf.option_context("mode.pandas_compatible", True):
result = df.sort_values(by="a", ascending=True)

assert_eq(expected, result)
Loading