Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,19 @@ class Categorical(NDArrayBackedExtensionArray, PandasObject):
['a', 'b', 'c', 'a', 'b', 'c']
Categories (3, object): ['a', 'b', 'c']

Missing values are not included as a category.

>>> c = pd.Categorical([1, 2, 3, 1, 2, 3, np.nan])
>>> c
[1, 2, 3, 1, 2, 3, NaN]
Categories (3, int64): [1, 2, 3]

However, their presence is indicated in the `codes` attribute
by code `-1`.

>>> c.codes
array([ 0, 1, 2, 0, 1, 2, -1], dtype=int8)

Ordered `Categoricals` can be sorted according to the custom order
of the categories and can have a min and max value.

Expand Down