represent_mixins_as_columns#
- astropy.table.represent_mixins_as_columns(tbl, exclude_classes=())[source]#
Represent input Table
tblusing onlyColumnorMaskedColumnobjects.This function represents any mixin columns like
Timeintblto one or more plain~astropy.table.Columnobjects and returns a new Table. A single mixin column may be split into multiple column components as needed for fully representing the column. This includes the possibility of recursive splitting, as shown in the example below. The new column names are formed as<column_name>.<component>, e.g.sc.rafor aSkyCoordcolumn namedsc.In addition to splitting columns, this function updates the table
metadictionary to include a dict named__serialized_columns__which provides additional information needed to construct the original mixin columns from the split columns.This function is used by astropy I/O when writing tables to ECSV, FITS, HDF5 formats.
Note that if the table does not include any mixin columns then the original table is returned with no update to
meta.- Parameters:
- Returns:
- tbl
Table New Table with updated columns, or else the original input
tbl
- tbl
Examples
>>> from astropy.table import Table, represent_mixins_as_columns >>> from astropy.time import Time >>> from astropy.coordinates import SkyCoord
>>> x = [100.0, 200.0] >>> obstime = Time([1999.0, 2000.0], format='jyear') >>> sc = SkyCoord([1, 2], [3, 4], unit='deg', obstime=obstime) >>> tbl = Table([sc, x], names=['sc', 'x']) >>> represent_mixins_as_columns(tbl) <Table length=2> sc.ra sc.dec sc.obstime.jd1 sc.obstime.jd2 x deg deg float64 float64 float64 float64 float64 ------- ------- -------------- -------------- ------- 1.0 3.0 2451180.0 -0.25 100.0 2.0 4.0 2451545.0 0.0 200.0