Numpy - asarray of a list, dimension not automatically set in the vector
numpy, python
Solution
>>> vec = np.asarray(l).reshape((1,-1))
>>> vec.shape
(1, 3)
I think is what you want ... maybe
Problem
I have a list of numbers ``` l = [ 1 , 3, 5] ``` I want to convert it to a numpy array vector ``` import numpy as np vec = np.asarray(l) ``` But the dimensions of vec is not set ``` vec.shape Answer: (3,) ``` I know I can do ``` vec.shape = (vec.shape[0], 1) ``` But is there any faster, shorter way to set the second dimension to one?