[AstroPy] Constructing an astropy table with colnames and dtypes of existing table
avillaum at ucsc.edu
Wed Apr 29 13:40:09 EDT 2015
I’m trying to construct an astropy table using the exact same columns and corresponding dtypes of an existing table. The documentation goes into using existing columns but it wasn’t as clear to me on how to handle the data types. For example, I have an existing table ‘irtf’ and I want to make a table ‘irtf_hb’ if I do,
irtf_hb = Table(names=irtf.colnames)
the table is initialized with all the right column names but the dtypes are all floats. However, I can’t do this,
irtf_hb = Table(names=irtf.colnames, dtype=irtf.dtype)
Because I get an error, “ValueError: dtype must be a list or None”. I haven’t had any luck with trying to change the type of irtf.dtype or using list comprehension to extract a list of dtypes.
Is there a simple way to use the dtypes of an existing table to initialize a new table?
More information about the AstroPy