<div dir="ltr">Hi Vitte,<div><br></div><div>Do you want to remove the rows from the original FITS file on disk or just from the table data that you are working with in memory?  </div><div><br></div><div>For the second option you need to generate a specification of the table indices for the rows you want to remove.  For instance, to remove row 0, or rows [2:5], or rows 1 and 3, the following examples (respectively) will work:</div><div><br></div><div><div><font face="monospace, monospace">>>> t.remove_row(0)</font></div><div><font face="monospace, monospace">>>> t.remove_rows(slice(2, 5))</font></div><div><font face="monospace, monospace">>>> t.remove_rows([1, 3])</font></div></div><div><br></div><div>So a simple way to do this might be :</div><div><br></div><div><font face="monospace, monospace">data = Table.read('data.fits')</font></div><div><font face="monospace, monospace">bad_rows = []</font></div><div><font face="monospace, monospace">for i_row, row in enumerate(data):</font></div><div><font face="monospace, monospace">    if (some condition of row):</font></div><div><font face="monospace, monospace">        bad_rows.append(i_row)</font></div><div><font face="monospace, monospace">data.remove_rows(bad_rows)</font></div><div><br></div><div>This isn't necessarily the fastest way but gets the job done.  If you can express the condition as an array comparison then it can be much faster.</div><div><br></div><div>Cheers,</div><div>Tom</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 20, 2017 at 9:19 AM, Eloïse Aurélie Bénédicte Vitte <span dir="ltr"><<a href="mailto:Eloise.Vitte@etu.unige.ch" target="_blank">Eloise.Vitte@etu.unige.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div id="m_-8039529312115931532divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hello,</p>
<p><br>
</p>
<p>I'm encountering a problem with a FITS file. I want to delete some rows that have certain values with a FOR loop in which I put IF conditions. It doesn't work when I use the function remove_row().</p>
<p><br>
</p>
<p>So, do you have any idea of the mistake I'm commiting ? </p>
<p><br>
</p>
<p>Kind regards,</p>
<p>Vitte Eloïse</p>
<p><br>
</p>
</div>
</div>

<br>______________________________<wbr>_________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@python.org">AstroPy@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/astropy</a><br>
<br></blockquote></div><br></div>