How to remove duplicate elements for two numpy arrays in python
问题 I have two array naming u,v, e.g. u=np.array([1.0,2.0,2.0,3.0,4.0]) v=np.array([10.0,21.0,18.0,30.0,40.0]) a=np.array([100.0,210.0,220.0,300.0,400.0]) If two elements in u are same, then delete that one which is higher in v value. For the above example,the result should be u_new=np.array([1.0,2.0,3.0,4.0]) v_new=np.array([10.0,18.0,30.0,40.0]) a_new=np.array([100.0,220.0,300.0,400.0]) def remove_duplicates(u,v,a): u_new, indices = np.unique(u, return_index=True) v_new = np.zeros(len(u_new),