Skip to content

Commit 6a368a7

Browse files
committed
fix doc string
1 parent dc71621 commit 6a368a7

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

pandas/core/arrays/categorical.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,16 +2038,15 @@ def mode(self, dropna=True):
20382038
def unique(self):
20392039
"""
20402040
Return the ``Categorical`` which ``categories`` and ``codes`` are
2041-
unique. Unused categories are NOT returned.
2041+
unique.
20422042
2043-
- unordered category: values and categories are sorted by appearance
2044-
order.
2045-
- ordered category: values are sorted by appearance order, categories
2046-
keeps existing order.
2043+
.. versionchanged:: 1.2.0
2044+
2045+
Previously unused categories were dropped.
20472046
20482047
Returns
20492048
-------
2050-
unique values : ``Categorical``
2049+
Categorical
20512050
20522051
See Also
20532052
--------
@@ -2057,23 +2056,11 @@ def unique(self):
20572056
20582057
Examples
20592058
--------
2060-
An unordered Categorical will return categories in the
2061-
order of appearance.
2062-
20632059
>>> pd.Categorical(list("baabc")).unique()
20642060
['b', 'a', 'c']
2065-
Categories (3, object): ['b', 'a', 'c']
2066-
2067-
>>> pd.Categorical(list("baabc"), categories=list("abc")).unique()
2068-
['b', 'a', 'c']
2069-
Categories (3, object): ['b', 'a', 'c']
2070-
2071-
An ordered Categorical preserves the category ordering.
2072-
2073-
>>> pd.Categorical(
2074-
... list("baabc"), categories=list("abc"), ordered=True
2075-
... ).unique()
2076-
['b', 'a', 'c']
2061+
Categories (3, object): ['a', 'b', 'c']
2062+
>>> pd.Categorical(list("baab"), categories=list("abc"), ordered=True).unique()
2063+
['b', 'a']
20772064
Categories (3, object): ['a' < 'b' < 'c']
20782065
"""
20792066
# unlike np.unique, unique1d does not sort

0 commit comments

Comments
 (0)