Determining the indicies where 2 numpy arrays differ
You can just write arr = arr_1 == arr_2. This code gives you a boolean array with true if they are equal and false if not. Then you can use np.where to find the indices where the arrays are equal or not.
I've got 2 long numpy arrays, both having 508 elements. I would like to get the indices of where they differ. Most of the solutions I've seen determining difference here sort the arrays which is not suitable in my case.
Example
arr_1 = [0, 1, 4, 0, 2, 2, 0, 3, 5, ... , 5, 5, 6]
arr_1 = [0, 1, 0, 0, 0, 2, 0, 3, 0, ... , 5, 0, 6]
Hopefully returning something like:
solut = [0, 0, 1, 0, 1, 0, 0, 0, 1, ... , 0, 1, 0]
or even
solut = [2, 4, 8, ..., n-2]
Is there an efficient way to do this in numpy?