From 4fda0c73fbbbd6c5178f3463ae875fa576d8ae4f Mon Sep 17 00:00:00 2001 From: Isaac Virshup Date: Wed, 17 Jan 2024 14:03:44 +0000 Subject: [PATCH 1/2] Document some more categorical methods --- pandas/core/arrays/categorical.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index eec833c600177..1c80fee22aeec 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -289,6 +289,15 @@ class Categorical(NDArrayBackedExtensionArray, PandasObject, ObjectStringArrayMi Methods ------- from_codes + as_ordered + as_unordered + set_categories + rename_categories + reorder_categories + add_categories + remove_categories + remove_unused_categories + map __array__ Raises From 39f3e313004c71386d451ddaa6557e15188adcf2 Mon Sep 17 00:00:00 2001 From: Isaac Virshup Date: Thu, 18 Jan 2024 13:43:45 +0000 Subject: [PATCH 2/2] Render pages for Categorical methods --- doc/source/reference/arrays.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index fe65364896f54..93b56d1b48c02 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -539,6 +539,21 @@ To create a Series of dtype ``category``, use ``cat = s.astype(dtype)`` or If the :class:`Series` is of dtype :class:`CategoricalDtype`, ``Series.cat`` can be used to change the categorical data. See :ref:`api.series.cat` for more. +More methods are available on :class:`Categorical`: + +.. autosummary:: + :toctree: api/ + + Categorical.as_ordered + Categorical.as_unordered + Categorical.set_categories + Categorical.rename_categories + Categorical.reorder_categories + Categorical.add_categories + Categorical.remove_categories + Categorical.remove_unused_categories + Categorical.map + .. _api.arrays.sparse: Sparse