How to extract all columns but one from an array (or matrix) in python?
Question: Given a numpy 2d array (or a matrix), I would like to extract all the columns
but the i-th.

E. g. from

    
    
    1 2 3 4
    2 4 6 8
    3 6 9 12
    

I would like to have, e.g.

    
    
    1 2 3
    2 4 6
    3 6 9
    

or

    
    
    1 2 4
    2 4 8
    3 6 12
    

I cannot find a pythonic way to do this. I now that you can extract given
columns by simply

    
    
    a[:,n]
    

or

    
    
    a[:,[n,n+1,n+5]]
    

But what about extracting all of them but one?


Answer: Take a look at numpy's [advanced
slicing](http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#boolean)

    
    
    >>> import numpy as np
    >>> a = np.array([[1,2,3,4], [2,4,6,8], [3,6,9,12]])
    >>> a[:,np.array([True, True, False, True])]
    array([[ 1,  2,  4],
           [ 2,  4,  8],
           [ 3,  6, 12]])
    

