If you want a one-liner from numpy and aren't too concerned about performance, try:
np.sum(np.diag(the_array,1),0)[:-1]
Explanation: np.diag(the_array,1)
creates a matrix with your array one-off the diagonal, np.sum(...,0)
sums the matrix column-wise, and ...[:-1]
takes the elements that would correspond to the size of the original array. Playing around with the 1
and :-1
as parameters can give you shifts in different directions.