I have 3 lists
x = [1,2,3,4,5,6]
y = [1,2,3,4,5,6]
z = [1,2,3,4,5,6]
Now I would like to extract the points. So that the final array would look like :
points = [[1,1,1], [2,2,2] ... ]
Is there an easy way to do it using numpy, than using the for loop?
CodePudding user response:
You can use zip and list:
points = list(zip(x,y,z))
You can also transpose a numpy array:
points = np.array([x,y,z]).T
And, you can stack them on dimensions you choose:
points = np.stack([x,y,z], 1)
CodePudding user response:
since my first guess with matrix turned out to be wrong, you just have to use a 2-dimensional array:
import numpy as np
a = np.array([x,y,z])
a[:,0]