dstack

astropy.table.dstack(tables, join_type='outer', metadata_conflicts='warn')[source]

Stack columns within tables depth-wise

A join_type of ‘exact’ means that the tables must all have exactly the same column names (though the order can vary). If join_type is ‘inner’ then the intersection of common columns will be the output. A value of ‘outer’ (default) means the output will have the union of all columns, with table values being masked where no common values are available.

Parameters:
tablesTable or Row or python:list thereof

Table(s) to stack along depth-wise with the current table Table columns should have same shape and name for depth-wise stacking

join_typepython:str

Join type (‘inner’ | ‘exact’ | ‘outer’), default is ‘outer’

metadata_conflictspython:str
How to proceed with metadata conflicts. This should be one of:
  • 'silent': silently pick the last conflicting meta-data value

  • 'warn': pick the last conflicting meta-data value, but emit a warning (default)

  • 'error': raise an exception.

Returns:
stacked_tableTable object

New table containing the stacked data from the input tables.

Examples

To stack two tables along rows do:

>>> from astropy.table import dstack, Table
>>> t1 = Table({'a': [1., 2.], 'b': [3., 4.]}, names=('a', 'b'))
>>> t2 = Table({'a': [5., 6.], 'b': [7., 8.]}, names=('a', 'b'))
>>> print(t1)
 a   b
--- ---
1.0 3.0
2.0 4.0
>>> print(t2)
 a   b
--- ---
5.0 7.0
6.0 8.0
>>> print(dstack([t1, t2]))
    a          b
---------- ----------
1.0 .. 5.0 3.0 .. 7.0
2.0 .. 6.0 4.0 .. 8.0