I have a numpy array with a shape of:
(11L, 5L, 5L)
I want to calculate the mean over the 25 elements of each \'slice\' of the array [0, :,
Use a tuple for axis :
>>> a = np.arange(11*5*5).reshape(11,5,5) >>> a.mean(axis=(1,2)) array([ 12., 37., 62., 87., 112., 137., 162., 187., 212., 237., 262.])
Edit: This works only with numpy version 1.7+.