sum over all but one axis

Vincent Schut schut at
Thu Oct 26 04:16:34 CDT 2006

Hi list,

probably I'm just missing something obvious, but I'm looking for a 
function/construcion to sum (or better, apply any numpy function) over 
all but one axis. Like when I have a nD array A, it will give me a 1D 
array with the sums of A[i, ...], but the axis that is retained in the 
result of course should be an argument to that function.
I thought 'apply_along_axis' would do the trick, but it does not. If I 
apply that to a 3d array, it results in a 2d array instead of a 1d array.

Of course I can easily loop over that axis, but if possible I'd like to 
prevent array loops...


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

More information about the Numpy-discussion mailing list