【python備忘録】numpyで縦ベクトルを作る

#Python
import numpy as np

np.arange(0,6)
# array([0, 1, 2, 3, 4, 5])

np.arange(0,6)[:, np.newaxis]
# array([[0],
#       [1],
#       [2],
#       [3],
#       [4],
#       [5]])

np.arange(0,6) + np.arange(0,6)[:, npnewaxis]
#array([[ 0,  1,  2,  3,  4,  5],
#       [10, 11, 12, 13, 14, 15],
#       [20, 21, 22, 23, 24, 25],
#       [30, 31, 32, 33, 34, 35],
#       [40, 41, 42, 43, 44, 45],
#       [50, 51, 52, 53, 54, 55]])

【python備忘録】numpyで縦ベクトルを作る” への2件のコメント

  1. I truly wanted to send a note to be able to thank you for all the awesome pointers you are showing at this website. My extensive internet research has at the end been rewarded with sensible tips to talk about with my friends and family. I would say that many of us site visitors are quite endowed to live in a really good community with many perfect professionals with good hints. I feel extremely happy to have discovered the website and look forward to so many more excellent times reading here. Thank you once more for everything.

コメントを残す

メールアドレスが公開されることはありません。