pandas.Index.intersection — pandas 1.0.1 documentation (original) (raw)

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

Form the intersection of two Index objects.

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

Parameters

otherIndex or array-like

sortFalse or None, default False

Whether to sort the resulting index.

New in version 0.24.0.

Changed in version 0.24.1: Changed the default from True to False, to match the behaviour of 0.23.4 and earlier.

Returns

intersectionIndex

Examples

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