I was wondering if there\'s a function that takes a list X
as input and outputs a column vector corresponding to X
?
(I looked around and I susp
A list is a native type of Python, whereas a numpy array is a numpy object. You will need to convert your list to a numpy array first. You can do something like the following.
x = list(range(5))
print(x)
[0, 1, 2, 3, 4]
x_vector = np.asarray(x)
array([0, 1, 2, 3, 4])
Now, Python does not know whats the difference between a row vector and a column vector, that is up to how you will use the vector. The current vector is 1x5. If you want 5x1, you can take the transpose by either
x_vector.T
or
np.transpose(x_vector)
However, since this is a 1D matrix, the transpose is the same as the non-transposed vector in memory.