0

I have two numpy arrays that were created by splitting one array. X has 7 columns and Y has 1 column.

I am filtering X with :

X[(X[:,2] != 0) & (X[:,1] != 0) & (X[:,3] != 0) & (X[:,4] != 0)]

This gives me the correct rows of X. How do I get the rows in Y with the matching row indices?

1 Answer 1

1

the same way you get X

mask = (X[:,2] != 0) & (X[:,1] != 0) & (X[:,3] != 0) & (X[:,4] != 0)
# mask is a list of [True,False,True,...]
print X[mask]
print Y[mask]
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Joran. This was just what I needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.