Series.unique()
[source]
Return unique values of Series object.
Uniques are returned in order of appearance. Hash table-based unique, therefore does NOT sort.
Returns: |
ndarray or Categorical The unique values returned as a NumPy array. In case of categorical data type, returned as a Categorical. |
---|
See also
pandas.unique
Index.unique
>>> pd.Series([2, 1, 3, 3], name='A').unique() array([2, 1, 3])
>>> pd.Series([pd.Timestamp('2016-01-01') for _ in range(3)]).unique() array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
>>> pd.Series([pd.Timestamp('2016-01-01', tz='US/Eastern') ... for _ in range(3)]).unique() array([Timestamp('2016-01-01 00:00:00-0500', tz='US/Eastern')], dtype=object)
An unordered Categorical will return categories in the order of appearance.
>>> pd.Series(pd.Categorical(list('baabc'))).unique() [b, a, c] Categories (3, object): [b, a, c]
An ordered Categorical preserves the category ordering.
>>> pd.Series(pd.Categorical(list('baabc'), categories=list('abc'), ... ordered=True)).unique() [b, a, c] Categories (3, object): [a < b < c]
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.Series.unique.html