for loop - Index of an array from a 2d np.array in Python? -


this question has answer here:

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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -