Skip to content

Commit

Permalink
sort out dataframe.to_numpy too
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Nov 2, 2024
1 parent 461244b commit 70809e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions narwhals/_pandas_like/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,6 @@ def to_numpy(self, dtype: Any = None, copy: bool | None = None) -> Any:
# pandas default differs from Polars, but cuDF default is True
copy = self._implementation is Implementation.CUDF

if dtype is not None:
return self._native_frame.to_numpy(dtype=dtype, copy=copy)

df = self.with_columns(
*[
self.__narwhals_namespace__()
Expand All @@ -712,6 +709,9 @@ def to_numpy(self, dtype: Any = None, copy: bool | None = None) -> Any:
]
)._native_frame

if dtype is not None:
return df.to_numpy(dtype=dtype, copy=copy)

# pandas return `object` dtype for nullable dtypes if dtype=None,
# so we cast each Series to numpy and let numpy find a common dtype.
# If there aren't any dtypes where `to_numpy()` is "broken" (i.e. it
Expand Down

0 comments on commit 70809e5

Please sign in to comment.