Find unique rows in numpy.array

后端 未结 20 3120
独厮守ぢ
独厮守ぢ 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条回答
  •  抹茶落季
    2020-11-21 11:46

    As of NumPy 1.13, one can simply choose the axis for selection of unique values in any N-dim array. To get unique rows, one can do:

    unique_rows = np.unique(original_array, axis=0)

提交回复
热议问题