Write a NumPy program to calculate the sum of all columns of a 2D NumPy array.Write a NumPy program to calculate the sum of all columns of a 2D NumPy array
Write a NumPy program to calculate the sum of all columns of a 2D NumPy array.Write a NumPy program to calculate the sum of all columns of a 2D NumPy array.
import numpy as np
num = np.arange(36)
arr1 = np.reshape(num, [4, 9])
print("Original array:")
print(arr1)
result = arr1.sum(axis=0)
print("\nSum of all columns:")
print(result)
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer