Replies: 1 comment 1 reply
-
It looks like you want to use Awkward's ragged indexing to pull items out of Awkward's ragged indexing requires that the structures of First we drop the final dimension of our index array so that it's compatible with ix = ak.flatten(b, axis=-1) Then we build an indexing result: temp = a[ix] Then we restore the structure of n_items = ak.ravel(ak.num(b, axis=-1)) Before finally unflattening our result result = ak.unflatten(temp, n_items, axis=-1) Does this behave as you expect? |
Beta Was this translation helpful? Give feedback.
-
Package versions:
awkward: 2.6.4
Problem
I would like to use a (N+1)-dim array to select elements form a N-dim array.
Example
I am having an array
a
with shapeN * var * int64
of the following kind:I have an array
b
of shapeN * var * var * int64
with indices that correspond to elements ina
:I would like to select the elements from
a
withb
. Expected result:Error
However, I get the error:
Other approaches
I have tried to use
ak.flatten()
withak.unflatten()
:However, this does not work with the empty lists. I found a similar issue in #905.
The other approach is to use
ak.cartesian()
:This works. But I am wondering if there is some advanced indexing to just use
a[b]
?Beta Was this translation helpful? Give feedback.
All reactions