1import numpy as np
2matrix=np.ones((10,10))
3print(matrix.sum(axis=0))
4print(matrix.sum(axis=1))
1>>> np.sum([[0, 1], [0, 5]])
26
3>>> np.sum([[0, 1], [0, 5]], axis=0)
4array([0, 6])
5>>> np.sum([[0, 1], [0, 5]], axis=1)
6array([1, 5])
7
8
1>>> np.sum([0.5, 1.5])
22.0
3>>> np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32)
41
5>>> np.sum([[0, 1], [0, 5]])
66
7>>> np.sum([[0, 1], [0, 5]], axis=0)
8array([0, 6])
9>>> np.sum([[0, 1], [0, 5]], axis=1)
10array([1, 5])
11>>> np.sum([[0, 1], [np.nan, 5]], where=[False, True], axis=1)
12array([1., 5.])
13