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?

Dharman
  • 30,962
  • 25
  • 85
  • 135

2 Answers2

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
Dharman
  • 30,962
  • 25
  • 85
  • 135
Niklas
  • 19
  • 3
0

Try this:

import numpy as np

someArray = [0]*10
print(np.transpose(someArray).reshape((len(someArray),1)))
MuzaffarShaikh
  • 380
  • 3
  • 13