How to calculate an ndarray array by specifying axis Calculate in column direction with 0 Calculate in the row direction with 1
python
import numpy as np
arr = np.array([[1, 2 ,3], [4, 5, 6]])
print(arr.sum())
print(arr.sum(axis=0))
print(arr.sum(axis=1))
python
>>>Output result
21
[5 7 9]
[ 6 15]
Recommended Posts