I would like to take bites out of a list (or array) of a certain size, return the average for that bite, and then move on to the next bite and do that all over again. Is there some way to do this without writing a for loop?
In [1]: import numpy as np
In [2]: x = range(10)
In [3]: np.average(x[:4])
Out[3]: 1.5
In [4]: np.average(x[4:8])
Out[4]: 5.5
In [5]: np.average(x[8:])
Out[5]: 8.5
I'm looking for something like, np.average(x[:bitesize=4]) to return: [1.5,5.5,8.5].
I have looked at slicing arrays and stepping through arrays, but I haven't found anything that does something like I want to have happen.