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

Remove drop_nan from internal IndexedFrame._drop_na_rows. #10140

Merged
merged 3 commits into from
Jan 27, 2022
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
26 changes: 8 additions & 18 deletions python/cudf/cudf/core/indexed_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,19 +1298,15 @@ def dropna(
0 Alfred Batmobile 1940-04-25
"""
if axis == 0:
result = self._drop_na_rows(
how=how, subset=subset, thresh=thresh, drop_nan=True
)
result = self._drop_na_rows(how=how, subset=subset, thresh=thresh)
else:
result = self._drop_na_columns(
how=how, subset=subset, thresh=thresh
)

return self._mimic_inplace(result, inplace=inplace)

def _drop_na_rows(
self, how="any", subset=None, thresh=None, drop_nan=False
):
def _drop_na_rows(self, how="any", subset=None, thresh=None):
"""
Drop null rows from `self`.

Expand All @@ -1324,8 +1320,6 @@ def _drop_na_rows(
thresh : int, optional
If specified, then drops every row containing
less than `thresh` non-null values.
drop_nan: bool
`nan` is also considered as `NA`
"""
if subset is None:
subset = self._column_names
Expand All @@ -1343,16 +1337,12 @@ def _drop_na_rows(
if len(subset) == 0:
return self.copy(deep=True)

data_columns = (
[
col.nans_to_nulls()
if isinstance(col, cudf.core.column.NumericalColumn)
else col
for col in self._columns
]
if drop_nan
else self._columns
)
data_columns = [
col.nans_to_nulls()
if isinstance(col, cudf.core.column.NumericalColumn)
else col
for col in self._columns
]

return self._from_columns_like_self(
libcudf.stream_compaction.drop_nulls(
Expand Down
14 changes: 0 additions & 14 deletions python/cudf/cudf/tests/test_dropna.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,3 @@ def test_dropna_multiindex_2(data, how):
got = gi.dropna(how)

assert_eq(expect, got)


@pytest.mark.parametrize("drop_nan", [True, False])
def test_drop_na_rows_dropnan(drop_nan):
col1 = cudf.Series([1, 2, np.nan], nan_as_null=False, dtype="float64")
gdf = cudf.DataFrame({"a": col1})

if drop_nan:
got = cudf.DataFrame({"a": [1, 2]}, dtype="float64")
else:
got = cudf.DataFrame({"a": col1})
expected = gdf._drop_na_rows(how="any", drop_nan=drop_nan)

assert_eq(expected, got)