Select column from a list

Bernhard Voigt bernhard.voigt at gmail.com
Fri Aug 28 09:53:49 EDT 2009


> >> I'm quite new in Python and I have one question. I have a 2D matrix of
> >> values stored in list (3 columns, many rows). I wonder if I can select one
> >> column without having to go through the list with 'for' command.

In case you want to due numerical calculations take a look at numpy it
has an extended slicing notation to select columns directly. See
http://www.scipy.org

# create 10x10 numpy array filled with 1
data = numpy.ones((10,10))
column = data[:,0]

Best wishes! Bernhard



More information about the Python-list mailing list