Jun-12-2018, 02:20 AM
In a numpy.ndarray (2d) I want to calculate the maximum of corresponding values (second column) of repetitive values (first column) in the array. Like if the array is this:
sys_func = array([[126. , 4], [126. , 11], [126. , 2], [126. , 12], [126. , 23], [126. , 1], [129. , 11], [129. , 45], [129. , 3], [129. , 125], [129. , 54], [129. , 1], [129. , 1], [129. , 53], [132. , 41], [132. , 1], [132. , 2], [142. , 6], [142. , 76 ]]) unique_days = [int(x) for x in np.unique(sys_func[:,0])]I want to get this:
[126 23; 129 125; 132 41; 142 76]I have tried the following:
max_sr = [] for i in range(len(unique_days)): s = [max(sys_func[:,1]) for x in np.where(sys_func[:,0] == unique_days[i])] max_sr.append(s)and it's obv giving me the wrong answer! Any ideas how to fix this?