I have a big numpy array and want to take the mean of the second columns of each two rows and save the array as a new one. I want to take the mean of each two row, i.e. the mean of second column of of rows 1 and 2. Then, mean of second column of rows 3 and 4, and so on. Then, I want to merge each two rows as a single one. First and third columns of this paired rows are also the same. This is my simplified array:
input= np.array ([[1., 2., 5.],
[1., 4., 5.],
[4., 10., 3.],
[4., 2., 3.],
[1., 0., 0.],
[1., 1., 0.]])
Then, I want to get:
output= np.array ([[1., 3., 5.],
[4., 6., 3.],
[1., 0.5, 0.]])
I tried the following but it was not successful at all:
output=np.array([])
for i in range (len(input)-1):
g=(input[i,1]+input[i+1,1])/2
output=np.append(g,output)
In advance, I do appreciate any help.