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:
tables : Table or list of Table objects

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

join_type : str

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

metadata_conflicts : 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_table : Table object

New table containing the stacked data from the input tables.

Examples

To stack two tables along rows do:

>>> from astropy.table import vstack, 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   3
  2   4
>>> print(t2)
 a   b
--- ---
  5   7
  6   8
>>> print(dstack([t1, t2]))
a [2]  b [2]
------ ------
1 .. 5 3 .. 7
2 .. 6 4 .. 8