Skip to content

NestedFrame constructor to pack series with hierarchical names #101

Open
@hombit

Description

@hombit

Feature request

It would be cool to allow users provide "layer.col" list-array series as input to NestedFrame so we automatically pack them.

nested_frame = NestedFrame(
    {
        {"id": [1,2,3]},
        {"lc.time": [0.1, 0.2], [0.1, 0.3], [0.2, 0.3, 0.4]},
        {"lc.counts": [100, 200], [55, 75], [33, 100, 155]},
    }
)

We can use it in reduce to allow a simple interface of generating new nested columns from it.

def apply_reference(ref_mag: float, ref_magerr: float, diff_mag: np.ndarray, diff_magerr: np.ndarray):
    mag = ref_mag + diff_mag
    magerr = np.hypot(ref_magerr, diff_magerr)
    return {"corrected_lc.mag": mag, "corrected_lc.magerr": magerr}

corrected_mag_df = nested_frame.reduce(apply_reference, "ref_mag", "ref_magerr", "lc.mag", "lc.magerr")
nested_frame = nested_frame.join(corrected_mag_df)
# Now nested_frame has "corrected_lc" column

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

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