Let
a = np.array([1, 1, 1,1,1,1])
b = np.array([2,2,2])
be two numpy arrays. Then let
c = [a]+[b]+[b]
clearly, c
has duplicated elements b
. Now I wish to remove one array b
from c
so that c
only contains one a
and one b
For removing duplicated elements in a list I usually used set()
. However, if, this time, I do
set(c)
I would receive error like
TypeError: unhashable type: 'numpy.ndarray'
In my understanding is that the numpy.ndarray
is not hashable.
The list c
above is just an example, in fact my c
could be very long. So, is there any good way to remove duplicated elements from a list of numpy.array?
Thx!
edit: I would expect my return to be c = [a]+[b]