[SciPy-user] array indices, column names

Peter Davenport pwdavenport@gmail....
Sat Oct 25 07:40:43 CDT 2008

I want to read in a tab separated data table (from excel), with row and column
names, then remove or add sets of columns to this table as required. 
The key here is to be able to read in a list of columns that I want to remove,
rather than doing it one at a time.

I'm a python novice who's dabbled in tcl and perl, I'm trying python and scipy
since they apparently handle matrixes better. 
I can't find a way of doing this in excel with data filters - hence my attempt
at python and scipy. 

I hope this post is clear, pls tell me if otherwise.

As far as I can see from the scipy cookbook and documentation, my best bet seems
to be as follows:

To read my table into python from a tab separated txt file and set it as an

    A = array([[columnnames, a, b, c, d]
        [row1, 1, 2, 3, 4]
        [row2, 5, 6, 7, 8]
        [row3, 9, 10, 11, 12]])

I can then get specific columns using,

and presumably it won't be too complex to create new array without these columns
in a manner such as:

    badcolumns = [1:2:4]

My issues is then, how do I turn a list of column names into a list of column
indices and then remove them from an array?

i.e. starting with a list of column names:

    badcnames = [a,b,d]

how do i get a list of indices:

    badcolumns = [1:2:4]

so that I can then remove them from the array.

Any advice greatly appreciated,


More information about the SciPy-user mailing list