[AstroPy] Removing rows from tables

Aldcroft, Thomas aldcroft at head.cfa.harvard.edu
Fri Jan 2 15:03:01 EST 2015


On Fri, Jan 2, 2015 at 1:48 PM, Knox Long <long at stsci.edu> wrote:

>  Is there a simple way to remove rows from an ascii table based on some
> condition without first converting table to a grouped_table.
>
>  I guess if if could determine how to create a slice based on a condition
> this would be possible.
>

You can use the `Table.remove_rows()` method (
http://astropy.readthedocs.org/en/stable/api/astropy.table.Table.html#astropy.table.Table.remove_rows
).

This will accept a slice or a list of row indexes.  If you have a boolean
mask then you can simply use that, e.g.:

>>> t = Table(....)
>>> remove_mask = t['a'] > 10  # for example
>>> t_new = t[~remove_mask]

Cheers,
Tom


>
>  Thanks,
> Knox
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150102/12db8ecb/attachment.html>


More information about the AstroPy mailing list