When I need to do such things, I prefer to convert a 2D array to a 3D array, and then reset the extra dimension using np.sum . Generalizing it to n-dimensional arrays, you can do something like this:
def sum_chunk(x, chunk_size, axis=-1): shape = x.shape if axis < 0: axis += x.ndim shape = shape[:axis] + (-1, chunk_size) + shape[axis+1:] x = x.reshape(shape) return x.sum(axis=axis+1) >>> a = np.arange(24).reshape(4, 6) >>> a array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]]) >>> sum_chunk(a, 2) array([[ 1, 5, 9], [13, 17, 21], [25, 29, 33], [37, 41, 45]]) >>> sum_chunk(a, 2, axis=0) array([[ 6, 8, 10, 12, 14, 16], [30, 32, 34, 36, 38, 40]])