「NumPy」array関数で二次元配列を作るサンプル

書式
import numpy as np
np.array([要素1,要素2],xxx)
array関数で二次元配列を作ります。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
'''元となる配列を作ります。'''
import numpy as np
arrcft = np.array([[21, 2], [43, 4], [65, 6]]) #二次元配列
print(arrcft)
'''元となる配列を作ります。''' import numpy as np arrcft = np.array([[21, 2], [43, 4], [65, 6]]) #二次元配列 print(arrcft)
'''元となる配列を作ります。'''
import numpy as np
arrcft = np.array([[21, 2], [43, 4], [65, 6]]) #二次元配列
print(arrcft)

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[[21 2]
[43 4]
[65 6]]
[[21 2] [43 4] [65 6]]
[[21  2]
 [43  4]
 [65  6]]

 

NumPy

Posted by arkgame