How to calculate the sum of every column in a NumPy array in Python

Calculating the sum of every column in a NumPy array results in a new array containing the sum of each column.

Solution for How to calculate the sum of every column in a NumPy array in Python : You can use numpy.ndarray.sum() to calculate the sum of each column Call numpy.ndarray.sum(axis=0) to calculate the sum of each column in numpy.ndarray. Setting axis to 1 would calculate the sum of each row.


how-to-calculate-the-sum-of-every-column-in-a-numpy-array-in-python