From 5687026ec3a00f1179a20c97fde91f7e7d09ec54 Mon Sep 17 00:00:00 2001 From: FBruzzesi Date: Thu, 15 Aug 2024 20:49:42 +0200 Subject: [PATCH] fix dask issue --- narwhals/_dask/dataframe.py | 11 +++++------ narwhals/_pandas_like/dataframe.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/narwhals/_dask/dataframe.py b/narwhals/_dask/dataframe.py index aefbc3b87..8bbcec135 100644 --- a/narwhals/_dask/dataframe.py +++ b/narwhals/_dask/dataframe.py @@ -129,14 +129,13 @@ def drop_nulls( ) column_names = [c for c in subset_ if isinstance(c, str)] - selectors = [c.is_null()._call(plx) for c in subset_ if isinstance(c, Selector)] + selector_names = self.select( + *[c.is_null()._call(plx) for c in subset_ if isinstance(c, Selector)] + ).columns - result = ( - self.filter(~plx.any_horizontal(plx.col(*column_names).is_null())) - if column_names - else self + return self._from_native_frame( + self._native_frame.dropna(subset=list(set(*column_names, *selector_names))) ) - return result.filter(~plx.any_horizontal(*selectors)) if selectors else result @property def schema(self) -> dict[str, DType]: diff --git a/narwhals/_pandas_like/dataframe.py b/narwhals/_pandas_like/dataframe.py index 5353d0498..67a11b2e5 100644 --- a/narwhals/_pandas_like/dataframe.py +++ b/narwhals/_pandas_like/dataframe.py @@ -253,7 +253,7 @@ def drop_nulls( selectors = [c.is_null()._call(plx) for c in subset_ if isinstance(c, Selector)] result = ( - self.filter(~plx.any_horizontal(plx.col(*column_names).is_null())) + (self._from_native_frame(self._native_frame.dropna(subset=column_names))) if column_names else self )