Skip to main content
Version: Python

merge

merge combines two or more tables into one aggregate table. This essentially appends the tables one on top of the other. Null tables are ignored.

Syntax

merge([tables...])

Parameters

ParameterTypeDescription
tablesTable...

Source tables to be merged.

  • The tables to be merged must include the same columns of the same type.
  • Null inputs are skipped.

Returns

A new table with the source tables stacked one on top of the other. The resulting table's rows will maintain the same order as the source tables. If the source tables tick, rows will be inserted within the merged table where they appear in the source (rather than at the end of the merged table).

Examples

In the following example, source1 is stacked on top of source2.

from deephaven import merge, merge_sorted, new_table
from deephaven.column import int_col, string_col

source1 = new_table([string_col("Letter", ["A", "B", "D"]), int_col("Number", [1, 2, 3])])
source2 = new_table([string_col("Letter", ["C", "D", "E"]), int_col("Number", [14, 15,16])])

result = merge([source1, source2])

In the following example, three tables are merged.

from deephaven import merge, merge_sorted, new_table
from deephaven.column import int_col, string_col

source1 = new_table([string_col("Letter", ["A", "B", "D"]), int_col("Number", [1, 2, 3])])
source2 = new_table([string_col("Letter", ["C", "D", "E"]), int_col("Number", [14, 15, 16])])
source3 = new_table([string_col("Letter", ["E", "F", "A"]), int_col("Number", [22, 25, 27])])

result = merge([source1, source2])

In the following example, three tables are merged using an array of tables.

from deephaven import merge, new_table
from deephaven.column import int_col, string_col

source1 = new_table([string_col("Letter", ["A", "B", "D"]), int_col("Number", [1, 2, 3])])
source2 = new_table([string_col("Letter", ["C", "D", "E"]), int_col("Number", [14, 15,16])])
source3 = new_table([string_col("Letter", ["E", "F", "A"]), int_col("Number", [22, 25, 27])])
tableArray = [source1, source2, source3]

result = merge(tableArray)