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, :,
You can reshape(11, 25) and then call mean only once (faster):
reshape(11, 25)
mean
a.reshape(11, 25).mean(axis=1)
Alternatively, you can call np.mean twice (about 2X slower on my computer):
np.mean
a.mean(axis=2).mean(axis=1)