np.sum() function do in NumPy?np.sum() adds up all the numbers in an array. It can add all elements or add along a specific direction (axis).
axis parameter in np.sum()?The axis parameter tells np.sum() which direction to add numbers along. For example, axis=0 adds down columns, axis=1 adds across rows.
np.sum(array, axis=0) do?It adds the numbers down each column and returns a 1D array with sums for each column.
np.sum() without specifying the axis?It adds all the numbers in the whole array and returns a single number.
axis=1 in np.sum() for a 2D array.axis=1 means add numbers across each row. The result is a 1D array with the sum of each row.
np.sum(array, axis=0) do for a 2D array?axis=0 sums down columns in a 2D array.
Without specifying axis, np.sum() adds all elements.
axis=1 mean in np.sum() for a 2D array?axis=1 sums across each row.
np.sum() return when you specify an axis?Specifying axis returns sums along that direction as an array.
axis=0 sums down columns in 2D arrays.
axis parameter changes the behavior of np.sum() when working with 2D arrays.np.sum() on a 3D array with axis=1.