Skip to content

Commit

Permalink
chore: simplify internal renaming in _pandas_like/series.py (#1847)
Browse files Browse the repository at this point in the history
chore: simplify _pandas_like/series.py renaming
  • Loading branch information
MarcoGorelli authored Jan 21, 2025
1 parent 38fadec commit a11843f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 250 deletions.
27 changes: 8 additions & 19 deletions narwhals/_pandas_like/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from narwhals._pandas_like.utils import create_compliant_series
from narwhals._pandas_like.utils import diagonal_concat
from narwhals._pandas_like.utils import horizontal_concat
from narwhals._pandas_like.utils import rename
from narwhals._pandas_like.utils import vertical_concat
from narwhals.typing import CompliantNamespace
from narwhals.utils import import_dtypes_module
Expand Down Expand Up @@ -267,18 +266,13 @@ def func(df: PandasLikeDataFrame) -> list[PandasLikeSeries]:

return [
PandasLikeSeries(
native_series=rename(
self.concat(
(s.to_frame() for s in series), how="horizontal"
)._native_frame.min(axis=1),
series[0].name,
implementation=self._implementation,
backend_version=self._backend_version,
),
self.concat(
(s.to_frame() for s in series), how="horizontal"
)._native_frame.min(axis=1),
implementation=self._implementation,
backend_version=self._backend_version,
version=self._version,
)
).alias(series[0].name)
]

return self._create_expr_from_callable(
Expand All @@ -298,18 +292,13 @@ def func(df: PandasLikeDataFrame) -> list[PandasLikeSeries]:

return [
PandasLikeSeries(
rename(
self.concat(
(s.to_frame() for s in series), how="horizontal"
)._native_frame.max(axis=1),
series[0].name,
implementation=self._implementation,
backend_version=self._backend_version,
),
self.concat(
(s.to_frame() for s in series), how="horizontal"
)._native_frame.max(axis=1),
implementation=self._implementation,
backend_version=self._backend_version,
version=self._version,
)
).alias(series[0].name)
]

return self._create_expr_from_callable(
Expand Down
Loading

0 comments on commit a11843f

Please sign in to comment.