Skip to content

Remove unwanted rows in array? #2156

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

You must be logged in to vote

I have to make some assumptions here; let me know if they are wrong!

  • I understand that your data can contain zeros, but the second index of the inner dimension (array[:, :, 1]) is zero if that "row" (axis=1) is missing.
  • I assume that your intended Awkward type is 1250 * var * 19, i.e. your final dimension is regular of length 19.

What you probably want to use here is Awkward's ragged indexing. We'll construct an array that indexes up to the second dimension, and ignore the empty rows.

First, let's convert the array to an Awkward Array

array = ak.from_numpy(input_events)

Now we can identify which rows are not padding, according to their second element

row_is_not_padding = array[:, :, 1] != 

Replies: 1 comment 5 replies

Comment options

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

@CaueSousa
Comment options

@CaueSousa
Comment options

@jpivarski
Comment options

@CaueSousa
Comment options

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