I have a 2D array and it has several repeating columns. I would like to see what unique columns are and where duplicates are.
My own array is too large to enter here, but here is an example:
a = np.array([[ 1., 0., 0., 0., 0.],[ 2., 0., 4., 3., 0.],])
It has a unique column vectors [1.,2.], [0.,0.], [0.,4.]and [0.,3.]. There is one duplicate: [0.,0.]appears twice.
Now I have found a way to get unique vectors and their indices here , but it is not clear to me how I will get duplicates as well. I tried several naive ways (with np.whereand a list of comps), but they are all very slow. Surely there should be a multi-bubble way?
In matlab is only a function unique, but np.uniquealigns arrays.
source
share