11
6

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.newaxisについて

Last updated at Posted at 2016-09-20

Pythonのnumpy.newaxisに関して情報が少なかったのでメモ.
用途は縦ベクトルへの変換.NumPyのReferenceによるとNoneのエイリアスらしいが,なぜNoneをスライスにつけると次元が増えるのかはイマイチ分からなかった.

import numpy as np

a = np.array([1,2,3,4,5])

b = a[:,np.newaxis]
print b # array([[1],[2],[3],[4],[5]])が出力

c = a[:,None]
print c # array([[1],[2],[3],[4],[5]])が出力
11
6
1

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
11
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?