Skip to content

Add Helper Function to split a Nested Column by a categorical column value #470

@dougbrn

Description

@dougbrn

Feature request
Splitting a nested structure into separate parts is probably a pretty common operation, especially splitting apart a Nested lightcurve into individual single-band lightcurves. It can be done relatively simply:

for band in nf["nested.band"].unique():
    nf[f"nested_{band}"] = nf.query(f"nested.band=='{band}'")["nested"]

but a direct helper function could be a nice value add. I'm not sure whether it would be best to add it as a NestedSeries function or a NestedFrame function, it would affect an individual NestedSeries so that is a strong argument, but NestedFrame handles a lot of the work of managing nested columns already and may lead to a cleaner workflow:

NestedSeries mockup

split_lcs = nf["nested"].split(by="band") # yields a NestedFrame
nf.join(split_lcs) # or perhaps direct assignment

NestedFrame mockup

nf = nf.split("nested", by="band") # directly handles new column creation on nf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions