Skip to content
Advertisement

Tag: average

Averaging over every n elements of a numpy array

I have a numpy array. I want to create a new array which is the average over every consecutive triplet of elements. So the new array will be a third of the size as the original. As an example: should return the array: Can anyone suggest an efficient way of doing this? I’m drawing blanks. Answer If your array arr

Advertisement