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

feat(python,rust): Implement pl.unnest Expr #3164

Closed
wants to merge 7 commits into from

Conversation

cjermain
Copy link
Contributor

This PR introduces a pl.unnest function for accessing nested struct columns, based on conversations in #3123. The goal is to allow a JSONPath-like string to index single or multiple columns that are nested at arbitrary depth.

  • Implement the actual path and unnesting logic
  • Add examples to the docs
  • Add tests

@github-actions github-actions bot added python Related to Python Polars rust Related to Rust Polars labels Apr 17, 2022
@cjermain cjermain changed the title pl.unnest Expr WIP: pl.unnest Expr Apr 17, 2022
@cjermain
Copy link
Contributor Author

The current implementation connects all the features end-to-end, but implements a very basic conversion from path to columns that needs to be replaced. You can try it out with:

import polars as pl

df = pl.DataFrame({'b': [1, 2, 3], 'c': [0, 0, 0]}).to_struct('a').to_frame()

df.select(pl.unnest('a.b'))

@cjermain
Copy link
Contributor Author

I'm planning to revisit this PR after solving an issue in json_path_match, which has some conceptual overlaps. #3373

@stinodego stinodego changed the title WIP: pl.unnest Expr feat(python,rust): Implement pl.unnest Expr Oct 1, 2022
@github-actions github-actions bot added the enhancement New feature or an improvement of an existing feature label Oct 1, 2022
@stinodego
Copy link
Member

I am closing this as the last update was over a year ago. Feel free to rebase and reopen this if you want to finish the PR.

@stinodego stinodego closed this Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants