I\'m trying to create a function that will calculate the lattice distance (number of horizontal and vertical steps) between elements in a multi-dimensional numpy array. For
Another possible solution:
import numpy as np A=np.array([[1,2,3],[4,5,6],[7,8,9]]) for _, val in np.ndenumerate(A): ind = np.argwhere(A==val) print val, ind
In this case you will obtain the array of indexes if value appears in array not once.