
上QQ阅读APP看书,第一时间看更新
Arithmetic operations
- Add all the elements of the array with the sum method. Go back to array_1:
array_1
array([[ 1, 2],
[ 3, 4],
[ 5, 6],
[ 7, 8],
[ 9, 10]])
array_1.sum()
55
- Find all the sums by row:
array_1.sum(axis = 1)
array([ 3, 7, 11, 15, 19])
- Find all the sums by column:
array_1.sum(axis = 0)
array([25, 30])
- Find the mean of each column in a similar way. Note that the dtype of the array of averages is np.float:
array_1.mean(axis = 0)
array([ 5., 6.])