1

For example, given a (10000, 250) sized numpy matrix A

>>>A.shape
(10000, 250)

and a numpy mask array m

>>>m = np.arange(0, A.shape[0], 3)
>>>m
([0, 3, 6, 9, ....., 9997])

This will select wanted column of A

>>>A[m]
>>>A[m].shape
(3333, 250)

But my question is. how to select the rest of the A? A[([1, 2, 4, 5, 7, 8, ...., 9998, 9999, 10000])]

1 Answer 1

2

You can use setdiff1d to select all indices that do not belong to m:

A[np.setdiff1d(np.arange(A.shape[0]), m)]
Sign up to request clarification or add additional context in comments.

Comments

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.