Skip to content

[Enh]: Chain operations before .over() for LazyFrames #3358

@naive-forecaster

Description

@naive-forecaster

We would like to learn about your use case. For example, if this feature is needed to adopt Narwhals in an open source project, could you please enter the link to it below?

No response

Please describe the purpose of the new feature or describe the problem to solve.

I want to create some chained transformations on a column:

nw.col('value').rolling_sum(window_size=10, min_samples=1).shift(2).over('id_col', order_by='date')

But LazyFrames only support some operations like rolling_sum right before an .over(order_by=...).

Would it be possible to make the over apply to all the operations that come before it?

Suggest a solution if possible.

No response

If you have tried alternatives, please describe them below.

I have also tried running an over after each function:

nw.col('value').over('id_col', order_by='date').rolling_sum(window_size=10, min_samples=1).shift(2).over('id_col', order_by='date')

But nested over clauses are not allowed.

Additional information that may help us understand your needs.

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions