l have 9000 array of arrays called my_data=(9000,). Each array is composed of a number of arrays.
len(my_data[0])=345 arrays# each array of 2000 values
len(my_data[700])=222 arrays s# each array of 2000 values
What l would like to do ?
Given two successive arrays, compute their mean and add the resulted mean vector between them.
What l have tried ?
new_data=[]
for i in np.arange(len(my_data)):
for j in np.arange(len(my_data[i]):
mean_arrays=np.mean(my_data[i][j],my_data[i][j+1],axis=0)
new_data.append(my_data[i][j]) # add the first array
new_data.append(mean_arrays) # add the mean of the two arrays
new_data.append(my_data[i][j+1]) # add the second array
new_data=np.asarray(new_data)
Is there any efficient way to compute that efficiently in less time and in pythonic way to avoid the nested for loops ?
Thank you
np.meantake one array argument only:np.mean(a, axis=None, dtype=None, out=None, keepdims=<no value>). What do you mean bynp.mean(my_data[i][j],my_data[i][j+1],axis=0)?