[SciPy-user] remove duplicate points...

Warren Weckesser warren.weckesser@gmail....
Wed Apr 23 20:37:47 CDT 2008


For kicks, here's a method that converts the array to a set, then back to an
array.

>>> z=numpy.array([[1,1],[1,2],[1,2],[1,3],[3,4],[5,0],[6,0],[5,0]])
>>> z
array([[1, 1],
       [1, 2],
       [1, 2],
       [1, 3],
       [3, 4],
       [5, 0],
       [6, 0],
       [5, 0]])
>>> uz = numpy.array([t for t in set([tuple(p) for p in z])])
>>> uz
array([[1, 2],
       [1, 3],
       [6, 0],
       [5, 0],
       [3, 4],
       [1, 1]])
>>>


On Wed, Apr 23, 2008 at 1:02 PM, Stéfan van der Walt <stefan@sun.ac.za>
wrote:

> 2008/4/23 Pierre GM <pgmdevlist@gmail.com>:
> >  The names don't matter, actually, they're just placeholders in our
> case.
>
> You can leave them out if you want:
>
> In [5]: np.dtype([('',int),('',int)])
> Out[5]: dtype([('f0', '<i4'), ('f1', '<i4')])
>
> Cheers
> Stéfan
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20080423/91a5f2a3/attachment.html 


More information about the SciPy-user mailing list