All Courses

How to split numpy array with mask?

By Asif92, 3 years ago
  • Bookmark
0

I want to split array into array with mask and index

like below

a = array([ 0,  1,  2,  3,  4, 5]))  
b = [0,2,3]  

into

c = array([[0, 2, 3], [1, 3, 4], [2, 4, 5]])  

can I do this without loop?

Edit:

More examples...

Say, we have an array a with shape [10, 10, 10]

where a[x, y, :] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Now given the mask b = [0, 3, 7]

I want the output to be an array c with shape [10, 10, 3, 3]

where c[x, y, :, :] = [[0, 3, 7], [1, 4, 8], [2, 5, 9]]

Numpy
Array
Slicing
0 Answer
Your Answer

Webinars

More webinars

Related Discussions

Running random forest algorithm with one variable

View More