I have three arrays
import numpy as np
value = np.array ([1, 3, 3, 5, 5, 7, 3])
index = np.array ([1, 1, 3, 3, 6, 6, 6])
data = np.array ([1, 2, 3, 4, 5, 6])
The arrays of "index" and "value" are the same size, and I want to group the elements into "value", averaging. For example: for the first two elements [1, 3, ... in the "value", they have the same key 1 in the "index", so for the final array, the value is the average value of the 1st and 2nd elements in the value: (1 + 3) / 2, equal to 2
Final array:
[2, nan, 4, nan, nan, 5]
the first value is the average value of the 1st and 2nd values "value" the
second value is nan, because there is no key in the "index" (there is no "2" in the array index)
The third value is the average value of the 3rd and 4 number of "value", ...
Thanks for the help!!!
Regards, Roy