Skip to content
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

enh: add LazyFrame.pivot #1901

Open
MarcoGorelli opened this issue Jan 31, 2025 · 0 comments
Open

enh: add LazyFrame.pivot #1901

MarcoGorelli opened this issue Jan 31, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@MarcoGorelli
Copy link
Member

This is something I'd quite like to see. In Polars too, but it's easier to implement here 😄

There's an example in the Polars docs about how to do a lazy pivot: https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.pivot.html

API-wise, we could have:

    def pivot(
        self: Self,
        on: str | list[str],
        *,
        column_names: list[str],
        index: str | list[str] | None = None,
        values: str | list[str] | None = None,
        aggregate_function: Literal[
            "min", "max", "sum", "mean", "median", "len"
        ]
        | None = None,
        separator: str = "_",
    ) -> Self:

This is very similar to DataFrame.pivot, but requires specifying the output column names explicitly so that the computation can stay completely lazy

@MarcoGorelli MarcoGorelli added the enhancement New feature or request label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant