1import numpy as np
2
3array1 = np.array(
4 [[1, 2],
5 [3, 4],
6 [5, 6]])
7
8total_0_axis = np.sum(array1, axis=0)
9print(f'Sum of elements at 0-axis is {total_0_axis}')
10
11total_1_axis = np.sum(array1, axis=1)
12print(f'Sum of elements at 1-axis is {total_1_axis}')
13Output:
14
15
16Sum of elements at 0-axis is [ 9 12]
17Sum of elements at 1-axis is [ 3 7 11]