pyspark.pandas.Index.intersection

Index.intersection(other: Union[pyspark.pandas.frame.DataFrame, pyspark.pandas.series.Series, Index, List]) → pyspark.pandas.indexes.base.Index[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
Returns
intersectionIndex

Examples

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