pyspark.pandas.MultiIndex.unique#
- MultiIndex.unique(level=None)#
Return unique values in the index.
Be aware the order of unique values might be different than pandas.Index.unique
- Parameters
- levelint or str, optional, default is None
- Returns
- Index without duplicates
Examples
>>> ps.DataFrame({'a': ['a', 'b', 'c']}, index=[1, 1, 3]).index.unique().sort_values() Index([1, 3], dtype='int64')
>>> ps.DataFrame({'a': ['a', 'b', 'c']}, index=['d', 'e', 'e']).index.unique().sort_values() Index(['d', 'e'], dtype='object')
MultiIndex
>>> ps.MultiIndex.from_tuples([("A", "X"), ("A", "Y"), ("A", "X")]).unique() ... MultiIndex([('A', 'X'), ('A', 'Y')], )