Skip to content

Introduce ["nested."] for flatten representation #231

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

Open
2 of 3 tasks
hombit opened this issue Apr 5, 2025 · 5 comments
Open
2 of 3 tasks

Introduce ["nested."] for flatten representation #231

hombit opened this issue Apr 5, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@hombit
Copy link
Collaborator

hombit commented Apr 5, 2025

Feature request

Maybe it is a weird idea, but we can provide a new interface for "flat" representation of a nested series within NestedFrame, using dot-prefix:

ndf["nested."] = flat_with_the_matched_index
assert_frame_equal(ndf["nested."], flat_with_the_matched_index)

It would simplify flattening and nesting (no add_nested) in simple cases.

Before submitting
Please check the following:

  • I have described the purpose of the suggested change, specifying what I need the enhancement to accomplish, i.e. what problem it solves.
  • I have included any relevant links, screenshots, environment information, and data relevant to implementing the requested feature, as well as pseudocode for how I want to access the new functionality.
  • If I have ideas for how the new feature could be implemented, I have provided explanations and/or pseudocode and/or task lists for the steps.
@hombit hombit added the enhancement New feature or request label Apr 5, 2025
@wilsonbb
Copy link
Contributor

wilsonbb commented Apr 7, 2025

Maybe we could have ndf["nested.flat"] with support for the shorthand of ndf["nested._"]

@hombit
Copy link
Collaborator Author

hombit commented Apr 7, 2025

Other options are ndf["nested.[]"] or ndf["nested.__flat__"]

@hombit
Copy link
Collaborator Author

hombit commented Apr 22, 2025

One more option is pseudo-methods, like ndf["nested.flat()"]

@dougbrn
Copy link
Collaborator

dougbrn commented Apr 29, 2025

Do we even need a convention? If a dataframe is assigned to a new base level column, it's probably sensible that nested-pandas would want to nest it. Could we just try the nest?

ndf["nested"] = flat_with_the_matched_index

@hombit
Copy link
Collaborator Author

hombit commented Apr 30, 2025

@dougbrn It is a good idea! It would be a bit weird if the flat data frame has a single column, because pandas kinda supports that operation, but I think it would be still nice to have!

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

3 participants