Skip to content

Row-level merging of similar arrays #2932

Answered by agoose77
artlbv asked this question in Q&A
Discussion options

You must be logged in to vote

@artlbv I think what you're asking for is provided by ak.concatenate, with the axis=1 argument:

import awkward as ak

barrel_eles = ak.from_iter([[{"pt": 43.8, "eta": -0.532}, {"pt": 39.5, "eta": 0.271}], [{"pt": 11.5, "eta": 0.951}]])
endcap_eles = ak.from_iter([[], [{"pt": 68.8, "eta": 1.92}, {"pt": 38, "eta": 1.6}]])

result = ak.concatenate((barrel_eles, endcap_eles), axis=1)

Under the hood, this will build a union like @ianna demonstrates, but this union will be erased as both arrays barrel_eles and endcap_eles have mergeable (the same!) types.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@artlbv
Comment options

Answer selected by artlbv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants