We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e45e3b4 commit 6b544deCopy full SHA for 6b544de
doc/source/categorical.rst
@@ -182,6 +182,23 @@ It's also possible to pass in the categories in a specific order:
182
indicate an ordered ``Categorical``.
183
184
185
+.. note::
186
+
187
+ The result of ``Series.unique()`` is not always the same as ``Series.cat.categories``,
188
+ because ``Series.unique()`` has a couple of guarantees, namely that it returns categories
189
+ in the order of appearance, and it only includes values that are actually present.
190
191
+ .. ipython:: python
192
193
+ s = pd.Series(list('babc')).astype('category', categories=list('abcd'))
194
+ s
195
196
+ # categories
197
+ s.cat.categories
198
199
+ # uniques
200
+ s.unique()
201
202
Renaming categories
203
~~~~~~~~~~~~~~~~~~~
204
0 commit comments