简体   繁体   中英

Unique symmetrical elements Numpy Array

I have a Numpy array as this:

 [1 4]
 [2 3]
 [3 0]
 [4 1]
 [5 6]
 [6 5]
 [7 6]]

This is output of NearestNeighbors algorithm of scikit-learn . I want to remove duplicated values. To have something like this:

[[0 3]
 [1 4]
 [2 3]
 [6 5]
 [7 6]]

I searched a lot, but not found any solution.

排序和np.unique一种方式 -

np.unique(np.sort(a, axis=1), axis=0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM