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

NestedFrame constructor to pack series with hierarchical names #101

Open
2 of 3 tasks
hombit opened this issue May 31, 2024 · 0 comments
Open
2 of 3 tasks

NestedFrame constructor to pack series with hierarchical names #101

hombit opened this issue May 31, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@hombit
Copy link
Collaborator

hombit commented May 31, 2024

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.
@hombit hombit added the enhancement New feature or request label May 31, 2024
@wilsonbb wilsonbb self-assigned this Nov 18, 2024
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

2 participants