「NumPy」numpy.emptyの使い方

書式
numpy.empty(shape, dtype = float, order = 'C’)
指定されたshapeを持つ、値が初期化されていない配列(ndarray)が返されます。
shape 生成する配列の形状(shape)を指定します。
dtype 省略可能(初期値float)生成される配列の要素のデータ型(dtype)を指定します。
order 省略可能(初期値’C’) 配列のデータの保存の仕方を指定します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
import numpy as np
x = np.empty([3,2], dtype = int)
print (x)
import numpy as np x = np.empty([3,2], dtype = int) print (x)
import numpy as np 
x = np.empty([3,2], dtype = int) 
print (x)

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[[ 6917529027641081856 5764616291768666155]
[ 6917529027641081859 -5764598754299804209]
[ 4497473538 844429428932120]]
[[ 6917529027641081856 5764616291768666155] [ 6917529027641081859 -5764598754299804209] [ 4497473538 844429428932120]]
[[ 6917529027641081856  5764616291768666155]
 [ 6917529027641081859 -5764598754299804209]
 [          4497473538      844429428932120]]

 

NumPy

Posted by arkgame