pandas.Index.union

Index.union(other, sort=True)[source]

Form the union of two Index objects.

Parameters:
other : Index or array-like
sort : bool, default True

Sort the resulting index if possible

New in version 0.24.0.

Returns:
union : Index

Examples

>>> idx1 = pd.Index([1, 2, 3, 4])
>>> idx2 = pd.Index([3, 4, 5, 6])
>>> idx1.union(idx2)
Int64Index([1, 2, 3, 4, 5, 6], dtype='int64')
Scroll To Top