Skip to content

Commit 9c11866

Browse files
authored
DOC: clarify default behavior for categories ordering (#22081)
1 parent 5d661c8 commit 9c11866

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: pandas/core/arrays/categorical.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,14 @@ class Categorical(ExtensionArray, PandasObject):
241241
categories will be replaced with NaN.
242242
categories : Index-like (unique), optional
243243
The unique categories for this categorical. If not given, the
244-
categories are assumed to be the unique values of values.
244+
categories are assumed to be the unique values of `values` (sorted, if
245+
possible, otherwise in the order in which they appear).
245246
ordered : boolean, (default False)
246247
Whether or not this categorical is treated as a ordered categorical.
247-
If not given, the resulting categorical will not be ordered.
248+
If True, the resulting categorical will be ordered.
249+
An ordered categorical respects, when sorted, the order of its
250+
`categories` attribute (which in turn is the `categories` argument, if
251+
provided).
248252
dtype : CategoricalDtype
249253
An instance of ``CategoricalDtype`` to use for this categorical
250254

0 commit comments

Comments
 (0)