I have a list (let's call it all_my_arrays
) that contains about 48,000 1D arrays. I'd like to know how many duplicate arrays are in this list, if any. However, I'd like to exclude empty arrays (because I have multiple empty arrays within the list and don't want those factored into my duplicate count). I tried this code below, but it is taking too long:
import numpy as np
uniques=[]
for arr in all_my_arrays:
if not np.array_equal(np.array([]), arr):
if not any(np.array_equal(arr, unique_arr) for unique_arr in uniques):
uniques.append(arr)
print(len(uniques)) #number of non-duplicates
Is there a much quicker way to accomplish this?