pyspark.pandas.MultiIndex.intersection

MultiIndex.intersection(other: Union[pyspark.pandas.frame.DataFrame, pyspark.pandas.series.Series, pyspark.pandas.indexes.base.Index, List]) → pyspark.pandas.indexes.multi.MultiIndex

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
intersectionMultiIndex

Examples

>>> midx1 = ps.MultiIndex.from_tuples([("a", "x"), ("b", "y"), ("c", "z")])
>>> midx2 = ps.MultiIndex.from_tuples([("c", "z"), ("d", "w")])
>>> midx1.intersection(midx2).sort_values()  
MultiIndex([('c', 'z')],
           )