I tried to find in stackoverflow a thread answering this question, but I could not find. Thus, if it is duplicate, please provide the link.
The use case is very common:
I have two arrays: X
which contains two dimensional datapoints and y
which contains labels either 0 or 1.
X
has shape (307, 2)
y
has shape (307, 1)
I want to have all rows in X
where the corresponding row in y
has value of 1.
I tried the following code:
X[y==1]
But it raises the following error:
IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1
How can I do that?