I have a numpy array that looks like this:
array([(1596207300, 1), (1596207300, 35), (1596207300, 36),
(1596207300, 41), (1596207300, 42), (1596207300, 44),
(1596207300, 49), (1596207300, 50), (1596207300, 51),
(1596207300, 60), (1596207300, 68), (1596207300, 69),
(1596207300, 81), (1596207300, 88), (1596207300, 96),
(1596207300, 115), (1596207300, 118), (1596207300, 123),
(1596207300, 125), (1596207300, 127), (1596207300, 128),
(1596207300, 129), (1596207300, 147), (1596207300, 150),
(1596207300, 156), (1596207300, 158), (1596207300, 162),
(1596207300, 164), (1596207300, 165), (1596207300, 170),
(1596207300, 171), (1596207300, 172), (1596207300, 173),
(1596207300, 188), (1596207300, 189), (1596207300, 202),
(1596207300, 241), (1596207300, 255), (1596207300, 257),
(1596207300, 258), (1596207300, 260), (1596207300, 275),
(1596207300, 276), (1596207300, 277), (1596207300, 278),
(1596207300, 279), (1596207300, 280), (1596207300, 283),
(1596207300, 285), (1596207300, 287), (1596207300, 296),
(1596207300, 301), (1596207300, 302), (1596207300, 303),
(1596207300, 313), (1596207300, 315), (1596207300, 316),
(1596208200, 321), (1596208200, 322), (1596208200, 323),
(1596208200, 348), (1596208200, 350), (1596208200, 352),
(1596208200, 360), (1596208200, 370), (1596208200, 371),
(1596208200, 373), (1596208200, 379), (1596208200, 380),
(1596212220, 389), (1596212220, 391), (1596212220, 392)],
dtype={'names':['time','value'], 'formats':['<u4','<u4'], 'offsets':[0,16], 'itemsize':20})
time column consists of timestamps (by minute). I want to extract rows with the biggest value per each time.
By [ arr[ arr['time'] == uTime ]['value'].max() for uTime in np.unique( arr['time'] ) ], I could get the biggest values per each time, which are [316, 380, 392], but I don't know how to simply extract the entire rows that contain the values.
The result I want to get:
array([(1596207300, 316), (1596208200, 380), (1596212220, 392)], dtype={'names':['time','value'], 'formats':['<u4','<u4'], 'offsets':[0,16], 'itemsize':20})