Skip to content

Commit

Permalink
split out
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Nov 11, 2024
1 parent 82bc7b8 commit 118c715
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 6 additions & 7 deletions narwhals/_arrow/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,17 +395,16 @@ def func(df: ArrowDataFrame) -> list[ArrowSeries]:
output_names = [input_series.name for input_series in input_series_list]
result = [function(series) for series in input_series_list]

if (
is_numpy_array(result[0])
or (np := get_numpy()) is not None
and np.isscalar(result[0])
):
if is_numpy_array(result[0]):
result = [
df.__narwhals_namespace__()
._create_compliant_series(array)
.alias(output_name)
if is_numpy_array(array)
else df.__narwhals_namespace__()
for array, output_name in zip(result, output_names)
]
elif (np := get_numpy()) is not None and np.isscalar(result[0]):
result = [
df.__narwhals_namespace__()
._create_compliant_series([array])
.alias(output_name)
for array, output_name in zip(result, output_names)
Expand Down
6 changes: 2 additions & 4 deletions narwhals/_pandas_like/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,8 @@ def func(df: PandasLikeDataFrame) -> list[PandasLikeSeries]:
input_series_list = self._call(df)
output_names = [input_series.name for input_series in input_series_list]
result = [function(series) for series in input_series_list]
if (
is_numpy_array(result[0])
or (np := get_numpy()) is not None
and np.isscalar(result[0])
if is_numpy_array(result[0]) or (
(np := get_numpy()) is not None and np.isscalar(result[0])
):
result = [
df.__narwhals_namespace__()
Expand Down

0 comments on commit 118c715

Please sign in to comment.