[Numpy-discussion] unique 2d arrays

josef.pktd@gmai... josef.pktd@gmai...
Tue Sep 21 09:57:08 CDT 2010


On Tue, Sep 21, 2010 at 2:55 AM, Peter Schmidtke
<pschmidtke@mmb.pcb.ub.es> wrote:
> 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.

One possibility see thread at
http://mail.scipy.org/pipermail/numpy-discussion/2009-August/044664.html

Josef



>
> Cheers.
>
> -- Peter Schmidtke
>
> PhD Student
> Dept. Physical Chemistry
> Faculty of Pharmacy
> University of Barcelona
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list