Skip to content

Select each row of data with different column indices #1906

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

You must be logged in to vote

Hi @r08222011

What you're describing here is an advanced index. NumPy has its own concept of this (that Awkward supports), e.g.

x1[[0, 1,2], [2, 0, 1]]

where each array in the subscript operation picks out a component from the corresponding dimension. In other words,

[[0, 1,2], [2, 0, 1]]

is interpreted as a one dimensional array of N dimensional tuples:

[(0, 2), (1, 0), (2, 1)] 

to build the result.

However, this means that the result is always one dimensional.

Awkward also has an additional indexing mode, if you pass in a ragged array which has the same number of dimensions as your x1 array (i.e. with length-1 lists in the final dimension), it will pick out the values you're interested …

Replies: 1 comment 3 replies

Comment options

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

@maplexgitx0302
Comment options

@agoose77
Comment options

Answer selected by maplexgitx0302
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