diff --git a/narwhals/_pandas_like/dataframe.py b/narwhals/_pandas_like/dataframe.py index 2fba95dfe..47c43a69a 100644 --- a/narwhals/_pandas_like/dataframe.py +++ b/narwhals/_pandas_like/dataframe.py @@ -767,19 +767,24 @@ def to_numpy(self, dtype: Any = None, copy: bool | None = None) -> Any: def to_pandas(self: Self) -> pd.DataFrame: if self._implementation is Implementation.PANDAS: return self._native_frame - if self._implementation is Implementation.MODIN: + elif self._implementation is Implementation.CUDF: # pragma: no cover + return self._native_frame.to_pandas() + elif self._implementation is Implementation.MODIN: return self._native_frame._to_pandas() - return self._native_frame.to_pandas() # pragma: no cover + msg = f"Unknown implementation: {self._implementation}" # pragma: no cover + raise AssertionError(msg) def to_polars(self: Self) -> pl.DataFrame: import polars as pl # ignore-banned-import if self._implementation is Implementation.PANDAS: return pl.from_pandas(self._native_frame) - if self._implementation is Implementation.MODIN: - return self._native_frame._to_polars() # type: ignore[no-any-return] - - raise NotImplementedError + elif self._implementation is Implementation.CUDF: # pragma: no cover + return pl.from_pandas(self._native_frame.to_pandas()) + elif self._implementation is Implementation.MODIN: + return pl.from_pandas(self._native_frame._to_pandas()) + msg = f"Unknown implementation: {self._implementation}" # pragma: no cover + raise AssertionError(msg) def write_parquet(self, file: Any) -> Any: self._native_frame.to_parquet(file) diff --git a/narwhals/_pandas_like/series.py b/narwhals/_pandas_like/series.py index db7cb0871..358041db7 100644 --- a/narwhals/_pandas_like/series.py +++ b/narwhals/_pandas_like/series.py @@ -842,7 +842,7 @@ def to_numpy(self, dtype: Any = None, copy: bool | None = None) -> Any: def to_pandas(self: Self) -> pd.Series: if self._implementation is Implementation.PANDAS: return self._native_series - elif self._implementation is Implementation.CUDF: + elif self._implementation is Implementation.CUDF: # pragma: no cover return self._native_series.to_pandas() elif self._implementation is Implementation.MODIN: return self._native_series._to_pandas() @@ -854,10 +854,12 @@ def to_polars(self: Self) -> pl.DataFrame: if self._implementation is Implementation.PANDAS: return pl.from_pandas(self._native_series) - if self._implementation is Implementation.MODIN: - return self._native_series._to_polars() # type: ignore[no-any-return] - - raise NotImplementedError + elif self._implementation is Implementation.CUDF: # pragma: no cover + return pl.from_pandas(self._native_series.to_pandas()) + elif self._implementation is Implementation.MODIN: + return pl.from_pandas(self._native_series._to_pandas()) + msg = f"Unknown implementation: {self._implementation}" # pragma: no cover + raise AssertionError(msg) # --- descriptive --- def is_duplicated(self: Self) -> Self: