[Numpy-discussion] How to remove any row or column of a numpy matrix whose sum is 3?
Mon Jun 4 11:21:02 CDT 2012
Hello every body. I am new to python.
How to remove any row or column of a numpy matrix whose sum is 3.
To obtain and save new matrix P with (sum(anyrow)!=3 and sum(anycolumn)!=3
I tried like this:
P = M[np.logical_not( (M[n,:].sum()==3) & (M[:,n].sum()==3))]
P = M[np.logical_not( (np.sum(M[n,:])==3) & (np.sum(M[:,n])==3))]
M is the nxn numpy matrix.
But I got indexerror. So can anyone correct this or any other elegant way
of doing this?
Thanks for your help
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion