-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow .collect() to be used on non-lazy DataFrames (as a no-op) #7882
Comments
Ahh I'd love this. I have a lot of: if isinstance(df, pl.LazyFrame):
df = df.collect() scattered throughout my codebase. |
This came up before. |
It's a duplicate of #6846.
I didn't understand the |
@StefanBRas that suggestion just moves the no-op from one place to another. Calling |
@mcrumiller I'm not sure I follow exactly what you're replying to. Just to be clear, I would like to have |
I wonder if having Each would work with DataFrame/LazyFrame input, but ignore the inapplicable class and return as-is; allows for easy construction of utility functions/pipelines that can work with both (which is the goal) but keeps the actual classmethods focused, and everyone who wants/needs this behaviour doesn't have to roll their own version... |
After spending some time grinding out a lot of data processing pipelines in Polars, I am convinced this is a good idea. A lot of my code is agnostic about eager/lazy, but there are parts where I want to enforce eager computation.
|
For now, we have decided not to implement this. See discussion in the linked PR #9676. Quoting Ritchie:
|
Problem description
I often have Polars pipelines that I would like to be able to easily switch between taking a DataFrame vs. a LazyFrame as an input.
This would be easier to reuse the same code if DataFrame had a .collect() method that does not do anything. This way I could easily make a function to implement a pipeline that works with both LazyFrame and DataFrames.
e.g.
I'd be happy to submit a PR for this, but wanted to check if there are any concerns or objections first.
The text was updated successfully, but these errors were encountered: