Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Bruzzesi <[email protected]>
  • Loading branch information
MarcoGorelli and FBruzzesi authored Nov 2, 2024
1 parent c5d8836 commit b393e42
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions narwhals/_pandas_like/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,19 +698,16 @@ 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

to_convert = set()
for key, val in self.schema.items():
if val == self._dtypes.Datetime and val.time_zone is not None: # type: ignore[attr-defined]
to_convert.add(key)
to_convert = {
key for key, val in self.schema.items()
if val == self._dtypes.Datetime and val.time_zone is not None # type: ignore[attr-defined]
}
if to_convert:
df = self.with_columns(
*[
self.__narwhals_namespace__()
.col(key)
.col(list(to_convert))
.dt.convert_time_zone("UTC")
.dt.replace_time_zone(None)
for key in to_convert
]
)._native_frame
else:
df = self._native_frame
Expand Down

0 comments on commit b393e42

Please sign in to comment.