pyspark.pandas.MultiIndex.unique¶
-
MultiIndex.
unique
(level: Union[int, Any, Tuple[Any, …], None] = None) → pyspark.pandas.indexes.base.Index¶ 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() ... Int64Index([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')], )