「NumPy」len関数で一次元配列の要素数を調べる

書式
配列名 = np.array([[要素1, 要素2, 要素3],xxx)
len(配列名)
len() 関数を利用して一次元配列の要素数(行数)を調べます。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
import numpy as np
arres = np.array([[31, 2, 3], [34, 5, 6], [37, 8, 9]])
print(len(arres))
import numpy as np arres = np.array([[31, 2, 3], [34, 5, 6], [37, 8, 9]]) print(len(arres))
import numpy as np
arres = np.array([[31, 2, 3], [34, 5, 6], [37, 8, 9]])

print(len(arres))

実行結果
3

NumPy

Posted by arkgame