[SciPy-user] Array manipulation

Stefan van der Walt stefan at sun.ac.za
Wed Feb 14 04:03:53 EST 2007


On Wed, Feb 14, 2007 at 09:02:34AM +0100, Nils Wagner wrote:
> Hi,
> 
> I would like to remove the i-th column and row from a two-dimensional
> array A. The remaining array
> should be kept and stored in B
> 
> A = random.rand(n,n)
> 
> This task is very easy if i is the first or last row/column. In that
> case one can use
> 
> B = A[1:,1:]
> 
> or
> 
> B=A[:-1,:-1]
> 
> But, what is the best way to get B  if  0 < i < n-1 ?

numpy.delete(x, i, 1)

Cheers
Stéfan



More information about the SciPy-User mailing list