I have a numpy array of shape (1200, 500, 1) and I want to resample it to the shape (1200, 50, 1) using a mean function.
What is a good and fast way to do this? Thanks
CodePudding user response:
If you need to apply the mean to every consecutive 10 items, you can do:
np.mean(arr.reshape(1200, 50, 10, 1), axis=2)
to split the items into buckets of 10 by reshape
and then apply mean
to the third axis.