I'm trying to remove any elements from an astropy table that have blank fields. However, all the help I have found so far just tells me how to replace it. I have tried replacing these blank fields (denoted by '--') with zeroes. However, whenever I try to filter them out with traditional python loops, they stay put. Is there no way I can remove rows that have blank fields in them?
from astropy.io import ascii
dat = ascii.read('exorgdatabase.txt')
dat['MSINI'].fill_value = 0
print(dat['MSINI'])
dat['PER'].fill_value = 0
print(dat['PER'])
newdat = dat.filled()
print(newdat)
while '0' in newdat['MSINI']:
newdat.remove('0')
print(newdat['MSINI'])
Here's the output I get:
MSINI
--------
mjupiter
--
--
--
0.310432
--
--
--
7.65457
--
...
--
--
--
--
--
--
--
--
--
--
--
Length = 5455 rows
PER
-----------
day
7.958203
3.27346074
19.12947337
10.290994
27.495606
9.478522
5.03728015
2.243752
7.8125124
...
7.227407
91.069934
366.084069
414.45008
5.43099314
328.32211
381.97977
67.412998
2.08802799
359.8249913
293.70696
Length = 5455 rows
NAME MSINI ... FIRSTURL
------------- -------- ... -------------------------------------------------
N/A mjupiter ... N/A
Kepler-107 d 0 ... http://adsabs.harvard.edu/abs/2014arXiv1402.6534R
Kepler-1049 b 0 ... http://adsabs.harvard.edu/abs/2016ApJ...822...86M
Kepler-813 b 0 ... http://adsabs.harvard.edu/abs/2016ApJ...822...86M
Kepler-427 b 0.310432 ... http://adsabs.harvard.edu/abs/2010Sci...327..977B
Kepler-1056 b 0 ... http://adsabs.harvard.edu/abs/2016ApJ...822...86M
Kepler-1165 b 0 ... http://adsabs.harvard.edu/abs/2016ApJ...822...86M
Kepler-1104 b 0 ... http://adsabs.harvard.edu/abs/2016ApJ...822...86M
WASP-14 b 7.65457 ... http://adsabs.harvard.edu/abs/2009MNRAS.392.1532J
Kepler-50 b 0 ... http://adsabs.harvard.edu/abs/2011ApJ...736...19B
... ... ... ...
KOI 2369.03 0 ... N/A
KOI 7572.01 0 ... N/A
KOI 7587.01 0 ... N/A
KOI 7589.01 0 ... N/A
KOI 2859.05 0 ... N/A
KOI 7591.01 0 ... N/A
KOI 7592.01 0 ... N/A
KOI 7593.01 0 ... N/A
KOI 7594.01 0 ... N/A
KOI 7596.01 0 ... N/A
KOI 7599.01 0 ... e
Length = 5455 rows
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-118-c200fae23235> in <module>()
23
24 while '0' in newdat['MSINI']:
---> 25 newdat.remove('0')
26
27 print(newdat['MSINI'])
AttributeError: 'Table' object has no attribute 'remove'