Skip to content

Commit

Permalink
fixup root names
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Feb 21, 2024
1 parent 2c1c6ed commit 953477c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion narwhals/pandas_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def evaluate_into_exprs(


def register_expression_call(expr: ExprT, attr: str, *args: Any, **kwargs: Any) -> ExprT:
from narwhals.pandas_like.expr import Expr
from narwhals.pandas_like.series import Series

plx = get_namespace(expr)
Expand All @@ -201,11 +202,19 @@ def func(df: DataFrame | LazyFrame) -> list[Series]:
out.append(plx._create_series_from_scalar(_out, column))
return out

root_names = expr._root_names
for arg in args:
if isinstance(arg, Expr):
root_names.extend(arg._root_names)
for arg in kwargs.values():
if isinstance(arg, Expr):
root_names.extend(arg._root_names)

return plx._create_expr_from_callable( # type: ignore[return-value]
func,
depth=expr._depth + 1,
function_name=f"{expr._function_name}->{attr}",
root_names=expr._root_names,
root_names=root_names,
output_names=expr._output_names,
)

Expand Down

0 comments on commit 953477c

Please sign in to comment.