From 6253f67e39c388a14880615437927690d589c801 Mon Sep 17 00:00:00 2001 From: Jordan Murphy <35613487+jordan-d-murphy@users.noreply.github.com> Date: Sun, 25 Feb 2024 00:22:52 -0700 Subject: [PATCH] fix ES01 for pandas.CategoricalDtype --- ci/code_checks.sh | 1 - pandas/core/dtypes/dtypes.py | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 47a2cf93a4f89..e6c47250afaa4 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -423,7 +423,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.Categorical.ordered\ pandas.Categorical.remove_unused_categories\ pandas.Categorical.rename_categories\ - pandas.CategoricalDtype\ pandas.CategoricalDtype.categories\ pandas.CategoricalDtype.ordered\ pandas.CategoricalIndex.as_ordered\ diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 12dcd8b0d42af..10635edb5e244 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -157,6 +157,17 @@ class CategoricalDtype(PandasExtensionDtype, ExtensionDtype): """ Type for categorical data with the categories and orderedness. + A categorical's type is fully described by + 1. categories: a sequence of unique values and no missing values + 2. ordered: a boolean + This information can be stored in a CategoricalDtype. The categories argument + is optional, which implies that the actual categories should be inferred from + whatever is present in the data when the pandas.Categorical is created. + The categories are assumed to be unordered by default. + + A CategoricalDtype can be used in any place pandas expects a dtype. For example + pandas.read_csv(), pandas.DataFrame.astype(), or in the Series constructor. + Parameters ---------- categories : sequence, optional