In [1]:
import numpy as np
import pandas as pd
In [2]:
pd.unique(pd.Series([2, 1, 1, 3, 4, 4,]))
Out[2]:
array([2, 1, 3, 4], dtype=int64)
In [3]:
pd.unique(pd.Series([3] + [2] * 5))
Out[3]:
array([3, 2], dtype=int64)
In [4]:
pd.unique(pd.Series([pd.Timestamp('20190101'),
                    pd.Timestamp('20190101')]))
Out[4]:
array(['2019-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
In [5]:
pd.unique(pd.Series([pd.Timestamp('20190101', tz='US/Eastern'),
                     pd.Timestamp('20190101', tz='US/Eastern')]))
Out[5]:
<DatetimeArray>
['2019-01-01 00:00:00-05:00']
Length: 1, dtype: datetime64[ns, US/Eastern]
In [9]:
pd.unique(pd.Index([pd.Timestamp('20190101', tz='US/Eastern'),
                    pd.Timestamp('20190101', tz='US/Eastern')]))
Out[9]:
DatetimeIndex(['2019-01-01 00:00:00-05:00'], dtype='datetime64[ns, US/Eastern]', freq=None)
In [10]:
pd.unique(list('qppqr'))
Out[10]:
array(['q', 'p', 'r'], dtype=object)

An unordered Categorical will return categories in the order of appearance.

In [11]:
pd.unique(pd.Series(pd.Categorical(list('qppqr'))))
Out[11]:
[q, p, r]
Categories (3, object): [q, p, r]
In [12]:
pd.unique(pd.Series(pd.Categorical(list('qppqr'),
                                   categories=list('pqr'))))
Out[12]:
[q, p, r]
Categories (3, object): [q, p, r]

An ordered Categorical preserves the category ordering.

In [14]:
pd.unique(pd.Series(pd.Categorical(list('qppqr'),
                                   categories=list('pqr'),
                                   ordered=True)))
Out[14]:
[q, p, r]
Categories (3, object): [p < q < r]

An array of tuples

In [15]:
pd.unique([('p', 'q'), ('q', 'p'), ('p', 'r'), ('q', 'p')])
Out[15]:
array([('p', 'q'), ('q', 'p'), ('p', 'r')], dtype=object)