From 9aa50ecd53e4ab7dad95cf3faa9f9687306bcf90 Mon Sep 17 00:00:00 2001 From: Pietro Battiston Date: Fri, 27 Jul 2018 12:36:32 +0200 Subject: [PATCH 1/2] DOC: clarify default behavior for categories ordering --- pandas/core/arrays/categorical.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 4584e4694cdc5..05efb75184606 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -241,10 +241,14 @@ class Categorical(ExtensionArray, PandasObject): categories will be replaced with NaN. categories : Index-like (unique), optional The unique categories for this categorical. If not given, the - categories are assumed to be the unique values of values. + categories are assumed to be the unique values of values (sorted, if + possible, otherwise in the order in which they appear). ordered : boolean, (default False) Whether or not this categorical is treated as a ordered categorical. - If not given, the resulting categorical will not be ordered. + If True, the resulting categorical will be ordered. + An ordered categorical respects, when sorted, the order of its + 'categories' attribute (which in turn is the 'categories' argument, if + provided). dtype : CategoricalDtype An instance of ``CategoricalDtype`` to use for this categorical From ddb03e487d24f9d98ff8bb375dba52c8c9b955ea Mon Sep 17 00:00:00 2001 From: Pietro Battiston Date: Mon, 30 Jul 2018 14:04:38 +0200 Subject: [PATCH 2/2] DOC: backticks --- pandas/core/arrays/categorical.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 05efb75184606..bf5b28205b57d 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -241,13 +241,13 @@ class Categorical(ExtensionArray, PandasObject): categories will be replaced with NaN. categories : Index-like (unique), optional The unique categories for this categorical. If not given, the - categories are assumed to be the unique values of values (sorted, if + categories are assumed to be the unique values of `values` (sorted, if possible, otherwise in the order in which they appear). ordered : boolean, (default False) Whether or not this categorical is treated as a ordered categorical. If True, the resulting categorical will be ordered. An ordered categorical respects, when sorted, the order of its - 'categories' attribute (which in turn is the 'categories' argument, if + `categories` attribute (which in turn is the `categories` argument, if provided). dtype : CategoricalDtype An instance of ``CategoricalDtype`` to use for this categorical