Reputation: 3241
I could not apply bool values into given data:
import numpy as np
bool_values = np.array([False, False, True, False, True])
data = np.array([[11.0, 22.0, 0.0, 44.0, 55.0],
[10.0, 20.0, 30.0, 40.0, 50.0]])
expected_answer = [[0,55], [30,50]]
I tried it as:
expected_answer = data[bool_values]
Upvotes: 1
Views: 59
Reputation: 394319
I think you wanted to do this:
In [28]:
bool_values = np.array([False, False, True, False, True])
data = np.array([[11.0, 22.0, 0.0, 44.0, 55.0],
[10.0, 20.0, 30.0, 40.0, 50.0]])
data[:,bool_values]
Out[28]:
array([[ 0., 55.],
[ 30., 50.]])
The above applies the mask to every row
Upvotes: 1