[AstroPy] saving tables as VOtables with missing values

Susana Sanchez Exposito sse at iaa.es
Wed Oct 15 04:22:20 EDT 2014


Hi all,

I work on an interface where the user can view and edit tables and save
them as VOtables, and for that I use the Astropy library.

I keep the data of the tables in python lists, so to save them as VOtable I
do this:

list = [["CIG1", 1.2, 3, "", 3], ["CIG1", 3, 2.0, 5, 2], ["CIG3", 2,
3,2.6,  float('nan')]]

#transform the list of rows into list of columns
list_cols= zip(*list)

tab=astropy.table.Table(list_cols, names=["A", "B", "C", "D", "E"])
votable=astropy.io.votable.from_table(tab)
votable.to_xml("/home/sse/Desktop/test.xml")

The table.Table method interprets correctly  the type of each column except
for the 3rd column. This column contains a "missing value" or maybe a value
deleted by the user, so the whole columns is marked as "string" type, when
actually is float type.

I could transform all empty strings into NaN but this will be strange for
those columns containing strings .

I have tried to transform the python list into a masked array, but without
success: problems to mask empty strings.

Maybe I should to find out the type of each columns, going over the table
and calculating the type of the majority of the column item, and then pass
this type array to the table.Table method in some way ??

So before, to continue investigating, I would like to ask you for some tips
to solve the missing values problems with astropy, or maybe even if there
is a specific method for that.

Thanks in advanced.

Susana.







-- 
Susana Sánchez Expósito

Instituto de Astrofísica de Andalucía   IAA (CSIC)
Camino Bajo de Huétor, 50. Granada E-18008
Tel:(+34) 958 121 311 / (+34) 958 230 618
Fax:(+34) 958 814 530
e-mail: sse at iaa.es
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20141015/33081f9d/attachment.html>


More information about the AstroPy mailing list