Finding unique points in numpy array

后端 未结 2 807
不思量自难忘°
不思量自难忘° 2020-12-16 03:40

What is a faster way of finding unique x,y points (removing duplicates) in a numpy array like:

points = numpy.random.randint(0, 5, (10,2))

2条回答
  •  鱼传尺愫
    2020-12-16 04:03

    I would do it like this:

    numpy.array(list(set(tuple(p) for p in points)))

    For the fast solution in the most general case, maybe this recipe would interest you: http://code.activestate.com/recipes/52560-remove-duplicates-from-a-sequence/

提交回复
热议问题