[Numpy-discussion] unique 2d arrays

Peter Schmidtke pschmidtke@mmb.pcb.ub...
Tue Sep 21 01:55:35 CDT 2010


Dear all,

I'd like to know if there is a pythonic / numpy way of retrieving unique
lines of a 2d numpy array.

In a way I have this :

[[409 152]
 [409 152]
 [409 152]
 [409 152]
 [409 152]
 [409 152]
 [409 152]
 [409 152]
 [409 152]
 [409 152]
 [409 152]
 [426 193]
 [431 129]]

And I'd like to get this :

[[409 152]
 [426 193]
 [431 129]]


How can I do this without workarounds like string concatenation or such
things? Numpy.unique flattens the whole array so it's not really of use
here.

Cheers.

-- Peter Schmidtke

PhD Student
Dept. Physical Chemistry
Faculty of Pharmacy
University of Barcelona



More information about the NumPy-Discussion mailing list