Let's say I have an array of 100 random numbers called random_array. I need to create an array that averages x numbers in random_array and stores them.
So if I had x = 7, then my code finds the average of the first 7 numbers and stores them in my new array, then next 7, then next 7...
I currently have this but I'm wondering how I can vectorize it or use some python method:
random_array = np.random.randint(100, size=(100, 1))
count = 0
total = 0
new_array = []
for item in random_array:
if (count == 7):
new_array.append(total/7)
count = 0
total = 0
else:
count = count + 1
total = total + item
print new_array