0

This is what I have:

someArray = [10]
print(np.tranpose(someArray))

and I'm getting: [0 0 0 0 0 0 0 0 0 0 0]

But I want it vertically. What am I doing wrong?

1

2 Answers 2

1

First, you have to convert your array to a numpy array, as long as this has not been done yet. Now you just have a 1D array. In Python, it is important to have a 2D array to perform some array/matrix operations. You just have to use an additional bracket pair [...]. Then you can simply use ".T" to transpose your array. Try this:

import numpy as np

someArray = [1,2,3,4,5,6,7,8]
someArray = np.array([someArray])
someArray_transposed = someArray.T
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

import numpy as np

someArray = [0]*10
print(np.transpose(someArray).reshape((len(someArray),1)))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.