@@ -219,19 +219,21 @@ def reuse_series_implementation(
219
219
plx = expr .__narwhals_namespace__ ()
220
220
221
221
def func (df : CompliantDataFrame ) -> list [CompliantSeries ]:
222
- out : list [CompliantSeries ] = []
223
- for column in expr ._call (df ): # type: ignore[arg-type]
224
- _out = getattr (column , attr )(
225
- * [maybe_evaluate_expr (df , arg ) for arg in args ],
226
- ** {
227
- arg_name : maybe_evaluate_expr (df , arg_value )
228
- for arg_name , arg_value in kwargs .items ()
229
- },
222
+ _args = [maybe_evaluate_expr (df , arg ) for arg in args ]
223
+ _kwargs = {
224
+ arg_name : maybe_evaluate_expr (df , arg_value )
225
+ for arg_name , arg_value in kwargs .items ()
226
+ }
227
+
228
+ out : list [CompliantSeries ] = [
229
+ plx ._create_series_from_scalar (
230
+ getattr (column , attr )(* _args , ** _kwargs ),
231
+ column , # type: ignore[arg-type]
230
232
)
231
- if returns_scalar :
232
- out . append ( plx . _create_series_from_scalar ( _out , column )) # type: ignore[arg-type]
233
- else :
234
- out . append ( _out )
233
+ if returns_scalar
234
+ else getattr ( column , attr )( * _args , ** _kwargs )
235
+ for column in expr . _call ( df ) # type: ignore[arg-type]
236
+ ]
235
237
if expr ._output_names is not None and (
236
238
[s .name for s in out ] != expr ._output_names
237
239
): # pragma: no cover
0 commit comments