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

dileep kunjaai dileepkunjaai at gmail.com
Thu Mar 24 05:06:35 EDT 2011


On Thu, Mar 24, 2011 at 1:12 PM, Sachin Kumar Sharma <SSharma84 at slb.com>wrote:

>  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 3
> rd 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 **
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
> I think u can use  numpy.loadtext command
http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html


-- 
DILEEPKUMAR. R
J R F, IIT DELHI
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110324/39e40243/attachment.html>


More information about the NumPy-Discussion mailing list