Can someone explain exactly what the axis
parameter in NumPy does?
I am terribly confused.
I\'m trying to use the function myArray.sum(ax
Both 1st and 2nd reply is great for understanding ndarray concept in numpy. I am giving a simple example.
And according to this image by @debaonline4u
https://i.stack.imgur.com/O5hBF.jpg
Suppose , you have an 2D array - [1, 2, 3] [4, 5, 6]
In, numpy format it will be -
c = np.array([[1, 2, 3],
[4, 5, 6]])
Now,
c.ndim = 2 (rows/axis=0)
c.shape = (2,3) (axis0, axis1)
c.sum(axis=0) = [1+4, 2+5, 3+6] = [5, 7, 9] (sum of the 1st elements of each rows, so along axis0)
c.sum(axis=1) = [1+2+3, 4+5+6] = [6, 15] (sum of the elements in a row, so along axis1)
So for your 3D array,