I have 5 numpy arrays:
array_1 = [1,2,3]
array_2 = [4,5,6]
array_3 = [7,8,9]
array_4 = [10,11,12]
array_5 = [1,2,3]
I need to compare them all - essentially, if ANY of the 5 arrays above have the same values (and index), I need to know about it. Currently, I have something like this done:
index_array_1 = np.where(array_1 == array_2)[0]
index_array_2 = np.where(array_1 == array_3)[0]
index_array_3 = np.where(array_1 == array_4)[0]
index_array_4 = np.where(array_1 == array_5)[0]
index_array_5 = np.where(array_2 == array_3)[0]
index_array_6 = np.where(array_2 == array_4)[0]
index_array_7 = np.where(array_2 == array_5)[0]
index_array_8 = np.where(array_3 == array_4)[0]
index_array_9 = np.where(array_3 == array_5)[0]
index_array_10 = np.where(array_4 == array_5)[0]
So, in this case, only index_array_4 would return any values, because array_1 and array_5 match up. But, this clearly isn't the best way to do this. It's a lot of code, and it takes a while to run as well.
Is there something I haven't come across yet where I can essentially say "if ANY of the 5 arrays match, tell me, and also let me know which two arrays are the ones that match"?
I'd also like it to return an index array of one of the matching arrays, as well.