最佳答案
>>> ex=np.arange(30)
>>> e=np.reshape(ex,[3,10])
>>> e
array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
[20, 21, 22, 23, 24, 25, 26, 27, 28, 29]])
>>> e>15
array([[False, False, False, False, False, False, False, False, False,
False],
[False, False, False, False, False, False, True, True, True,
True],
[ True, True, True, True, True, True, True, True, True,
True]], dtype=bool)
I need to find the rows that have true or rows in e
whose value are more than 15. I could iterate using a for loop, however, I would like to know if there is a way numpy could do this more efficiently?