for loop - Index of an array from a 2d np.array in Python? -
this question has answer here:
- numpy index value true 2 answers
i have problem find index 2d np.array()
. if-loop computing time high algorithm. need numpy func find index array. function np.where()
doesn’t me.. abstraction:
>>> conditions = [[0 0 0 0 4] [0 0 0 0 3] [0 0 0 0 2] ..., [2 1 3 4 2] [2 1 3 4 1] [2 1 3 4 0]] >>> = [0, 0, 0, 0, 2] >>> index = np.where(conditions==a)
if use so, although have column , row indices, can not interpret them. need concrete index value, example index = 2
.
>>> np.where((conditions == a).all(axis=1))[0] array([2])
Comments
Post a Comment