pandas 1.4.2

NotesReturnsBackRef
unique(self) -> 'ArrayLike'

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

Notes

Returns the unique values as a NumPy array. In case of an extension-array backed Series, a new ~api.extensions.ExtensionArray of that type with just the unique values is returned. This includes

See Examples section.

Returns

ndarray or ExtensionArray

The unique values returned as a NumPy array. See Notes.

Return unique values of Series object.

See Also

Index.unique

Return Index with unique values from an Index object.

unique

Top-level unique method for any 1-d array-like object.

Examples

This example is valid syntax, but we were not able to check execution
>>> pd.Series([2, 1, 3, 3], name='A').unique()
array([2, 1, 3])
This example is valid syntax, but we were not able to check execution
>>> pd.Series([pd.Timestamp('2016-01-01') for _ in range(3)]).unique()
array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
This example is valid syntax, but we were not able to check execution
>>> pd.Series([pd.Timestamp('2016-01-01', tz='US/Eastern')
...  for _ in range(3)]).unique() <DatetimeArray> ['2016-01-01 00:00:00-05:00'] Length: 1, dtype: datetime64[ns, US/Eastern]

An Categorical will return categories in the order of appearance and with the same dtype.

This example is valid syntax, but we were not able to check execution
>>> pd.Series(pd.Categorical(list('baabc'))).unique()
['b', 'a', 'c']
Categories (3, object): ['a', 'b', 'c']
This example is valid syntax, but we were not able to check execution
>>> pd.Series(pd.Categorical(list('baabc'), categories=list('abc'),
...  ordered=True)).unique() ['b', 'a', 'c'] Categories (3, object): ['a' < 'b' < 'c']
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.indexes.base.Index.unique pandas.core.algorithms.unique pandas.core.series.Series.unique pandas.core.indexes.multi.MultiIndex.unique pandas.core.arrays.categorical.Categorical.unique

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/series.py#2030
type: <class 'function'>
Commit: