My goal is to take a list of np.arrays and create an associated list or array that classifies each as having a duplicate or not. Here's what I thought would work:
www = [np.array([1, 1, 1]), np.array([1, 1, 1]), np.array([2, 1, 1])] uniques, counts = np.unique(www, axis = 0, return_counts = True) counts = [1 if x > 1 else 0 for x in counts] count_dict = dict(zip(uniques, counts)) [count_dict[i] for i in www] The desired output for this case would be :
[1, 1, 0]
because the first and second element have another copy within the original list. It seems that the problem is that I cannot use a np.array as a key for a dictionary.
Suggestions?
wwwalways the same size?