datatable.union()

Find the union of values in all frames.

Each frame should have only a single column or be empty. The values in each frame will be treated as a set, and this function will perform the union operation on these sets.

The dt.union(*frames) operation is equivalent to dt.unique(dt.rbind(*frames)).

Parameters

*frames
Frame | Frame | ...

Input single-column frames.

return
Frame

A single-column frame. The column stype is the smallest common stype of columns in the frames.

except
ValueError | NotImplementedError

dt.exceptions.ValueError

raised when one of the input frames has more than one column.

dt.exceptions.NotImplementedError

raised when one of the columns has stype obj64.

Examples

from datatable import dt, f, by df = dt.Frame({'A': [1, 1, 2, 1, 2], 'B': [None, 2, 3,4, 5], 'C': [1, 2, 1, 1, 2]}) df
ABC
int32int32int32
01NA1
1122
2231
3141
4252

Union of all the columns in a frame:

dt.union(*df)
A
int32
0NA
11
22
33
44
55

Union of two frames:

dt.union(df["A"], df["C"])
A
int32
01
12

See Also

  • intersect() – calculate the set intersection of values in the frames.

  • setdiff() – calculate the set difference between the frames.

  • symdiff() – calculate the symmetric difference between the sets of values in the frames.

  • unique() – find unique values in a frame.