axisを指定してndarray配列を計算する方法
0で列方向に計算
1で行方向に計算
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))
>>> 出力結果
21
[5 7 9]
[ 6 15]
Go to list of users who liked
More than 5 years have passed since last update.
axisを指定してndarray配列を計算する方法
0で列方向に計算
1で行方向に計算
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))
>>> 出力結果
21
[5 7 9]
[ 6 15]
Register as a new user and use Qiita more conveniently
Go to list of users who liked