0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Numpy操作まとめ

Last updated at Posted at 2019-05-05

Numpyの操作方法をまとめておく

import numpy as np

# 型を指定して配列を作成
np.array([1,2,3,4], dtype='float32')
np.array([range(i, i+3) for i in [2, 4, 6]])

# 値を指定して配列を作る
np.zeros((2, 3), dtype='int')
np.ones((3, 5),dtype=float)
np.full((3,5), 3.14)

# 範囲を指定した配列
np.arange(0, 20, 2)
np.linspace(0, 20, 5)

# 0 から 1の範囲内のランダムな値で配列を作る
np.random.random((3,3))
# 0 から 10の整数の範囲内のランダムな値で配列を作る
np.random.randint(0, 10, (3, 3))

# 単位行列
np.eye(3)

# メモリから値を取得
np.empty(3)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?