pandas.Index.intersection

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

Form the intersection of two Index objects.

This returns a new Index with elements common to the index and other.

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

Sort the resulting index if possible

New in version 0.24.0.

Returns:
intersection : Index

Examples

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