Find unique rows in numpy.array

后端 未结 20 2877
独厮守ぢ
独厮守ぢ 2020-11-21 10:57

I need to find unique rows in a numpy.array.

For example:

>>> a # I have
array([[1, 1, 1, 0, 0, 0],
       [0, 1, 1, 1, 0, 0],
         


        
20条回答
  •  -上瘾入骨i
    2020-11-21 12:01

    The numpy_indexed package (disclaimer: I am its author) wraps the solution posted by Jaime in a nice and tested interface, plus many more features:

    import numpy_indexed as npi
    new_a = npi.unique(a)  # unique elements over axis=0 (rows) by default
    

提交回复
热议问题