Reputation: 730
I have two arrays y
dims (1x100)
and X
dims (3x100)
I want to select all those values from X
where y
is 0 and all values where y
is 1.
I have tried doing X[y==0]
to get all those values where y
is 0 but it doesn't work for dim 0 of X
which is 3.
Any suggestions on how to do it?
Thanks
Upvotes: 0
Views: 30
Reputation: 294488
You need to align dimensions correctly
X[:, y[0] == 0]
The first :
specifies to grab everything in the first dimension. Using the y[0] == 0
in the second slot specifies that we are indexing the second dimension.
Upvotes: 1