0

What is the most efficient way to mask columns from a numpy array?

a = np.arange(12).reshape((3,4))
mask = [True False True False]

I'm looking for something like:

b = a[mask, axis=1]

which would give the output:

b = [[0, 2],[4, 6], [8, 10]]

I need this for a large array.

Thanks,

2

0

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.