Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you are working from a matrix and want (column) vectors, you can do:

a=matrix([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
v0=a[:,0]
v0

If your data is in a list, you can use list comprehensions in python.

a=[[1,2,3,4],[5,6,7,8],[9,10,11,12]]
v1=[row[0] for row in a]
v1

You can do it all at once with:

a1=[[r[i] for r in a] for i in range(len(a))]
a1