pyspark.pandas.Series.unique

Series.unique() → pyspark.pandas.series.Series[source]

Return unique values of Series object.

Uniques are returned in order of appearance. Hash table-based unique, therefore does NOT sort.

Note

This method returns newly created Series whereas pandas returns the unique values as a NumPy array.

Returns
Returns the unique values as a Series.

Examples

>>> psser = ps.Series([2, 1, 3, 3], name='A')
>>> psser.unique().sort_values()
1    1
0    2
2    3
Name: A, dtype: int64
>>> ps.Series([pd.Timestamp('2016-01-01') for _ in range(3)]).unique()
0   2016-01-01
dtype: datetime64[ns]
>>> psser.name = ('x', 'a')
>>> psser.unique().sort_values()
1    1
0    2
2    3
Name: (x, a), dtype: int64