[Numpy-discussion] How operating arrays in a determined axis?
focke at slac.stanford.edu
Mon Mar 19 16:40:54 EST 2001
On Mon, 19 Mar 2001, Aureli Soria Frisch wrote:
> I have a N-dimensional array A and I want to operate in one of the axis (k)
> with a 1 dimensional array (for instance, subtracting an array B of length
> k). I have looked for some solutions in the manual and did not found any.
> So after testing a lot I found following solution:
> A.shape=(a1,a2,...,ak,...,aN) #where N is any int value
newshape =  * len(A.shape)
newshape[k] = A.shape[k]
B.shape = newshape
result = A - B
More information about the NumPy-Discussion