[Numpy-discussion] how to delete a particular column or row from numpy array based on some rule or value

Sachin Kumar Sharma SSharma84@slb....
Thu Mar 24 02:42:47 CDT 2011


BB,

In a numpy array of m x n size, I would like to delete few rows when a given element in that row is 'nan' or say any other value.

For e.g.  as in example given below, if I wish to delete a row when the 3rd element of row is zero, or if 3rd, 4th, 5th element are zero or either of 3rd, 4th and 5th element is zero.
array([[ 1900. ,     nan,     nan,     nan,     nan,     nan],
       [ 1900.5,     nan,     nan,     nan,     nan,     nan],
       [ 1901. ,     nan,     nan,     nan,     nan,     nan],
       ...,
       [ 6724. ,     nan,     nan,     nan,     nan,     nan],
       [ 6724.5,     nan,     nan,     nan,     nan,     nan],
       [ 6725. ,     nan,     nan,     nan,     nan,     nan]])
Cheers

Sachin
************************************************************************
Sachin Kumar Sharma
Senior Geomodeler

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110324/30dfa01c/attachment.html 


More information about the NumPy-Discussion mailing list