Skip to content

How to combine a list of awkward arrays ? #1251

Answered by jpivarski
MoAly98 asked this question in Q&A
Discussion options

You must be logged in to vote

Now I wish the string representation of Awkward Arrays and Records didn't look so much like Python lists and dicts, because Python data type is important for this question!

ak.concatenate is the right function to use, though you can only use it without qualification if you really do have two Awkward Arrays:

>>> one = ak.Array([{"x": 20, "y": [1, 2, 3, 4, 5]}])
>>> two = ak.Array([{"x": 30, "y": [6, 7, 8, 9, 10]}])
>>> onetwo = ak.concatenate([one, two])
>>> onetwo.tolist()
[{'x': 20, 'y': [1, 2, 3, 4, 5]}, {'x': 30, 'y': [6, 7, 8, 9, 10]}]

You wanted the x data and the y data in separate arrays, so

>>> onetwo.x
<Array [20, 30] type='2 * int64'>
>>> onetwo.y
<Array [[1, 2, 3, 4, 5], [6, 7, 8

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by MoAly98
Comment options

You must be logged in to vote
4 replies
@jpivarski
Comment options

@MoAly98
Comment options

@jpivarski
Comment options

@MoAly98
Comment options

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