I want to go through the list_
function within the numpy array and much like a for loop I want the mean to be calculated of every 3 numbers in the list. So the y_mean
would be calculated with the first 3 values 457.334015,424.440002,394.795990
and then it will be calculated with the next 3 values 424.440002,394.795990,408.903992
and so on. The y_mean
function does not work below is there a way I could fix it.
import numpy as np
list_= np.array([457.334015,424.440002,394.795990,408.903992,398.821014,402.152008,435.790985,423.204987,411.574005,
404.424988,399.519989,377.181000,375.467010,386.944000,383.614990,375.071991,359.511993,328.865997,
320.510010,330.079010,336.187012,352.940002,365.026001,361.562012,362.299011,378.549011,390.414001,
400.869995,394.773010,382.556000])
number = 3
start = np.arange(start=1, stop=len(list_)-number, step=1)
stop = np.arange(start=number+1, stop=len(list_), step=1)
y_mean = list_[start:stop].mean()
print(y_mean)