greg whittier <gregwh <at> gmail.com> writes: > > a = np.arange(27).reshape(3,3,3) > > # sum over axis 1 and 2 > result = a.reshape((a.shape[0], a.shape[1]*a.shape[2])).sum(axis=1) > > Is there a cleaner way to do this? I'm sure I'm missing something obvious. >
Only slightly more convenient is: a.reshape(a.shape[0], -1).sum(-1) HTH, Dave _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
