Jun-12-2018, 08:32 AM
You can obtain it in a one line:
>>> m = np.array([[126. , 4],...) >>> list((x, max(m[m[:,0]==x, 1])) for x in np.unique(m[:, 0])) [(126.0, 23.0), (129.0, 125.0), (132.0, 41.0), (142.0, 76.0)] # Or as a numpy array >>> np.array(list((x, max(m[m[:,0]==x, 1])) for x in np.unique(m[:, 0]))) array([[126., 23.], [129., 125.], [132., 41.], [142., 76.]])But it might look too much as black magic with that level of nested parenthesis and brackets... I will for sure add some comments explaining what I want to obtain.