python - Splitting columns of a numpy array easily -


how can split array's columns 3 arrays x, y, z without manually writing each of [:,0],[:,1],[:,2] separately?

import numpy np data = np.array([[1,2,3],[4,5,6],[7,8,9]]) print data  [[1 2 3]  [4 5 6]  [7 8 9]]    x, y, z = data[:,0], data[:,1], data[:,2] ## me here! print x  array([1, 4, 7]) 

transpose, unpack:

>>> x, y, z = data.t >>> x array([1, 4, 7]) 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -