$ x = np.arange(5)
$ x
array([0, 1, 2, 3, 4])
Two different methods:
$ x
array([0, 1, 2, 3, 4])
Two different methods:
$ x.reshape(-1,1)
array([[0],
[1],
[2],
[3],
[4]])
$ np.c_[x]
array([[0],
[1],
[2],
[3],
[4]])
Another common method I have seen is
ReplyDeletex[:,np.newaxis]
I first read about this method in The Python Data Science Handbook by Jake VanderPlas
Thanks, I never used that one before.
ReplyDelete