From 31dc1386d04a986240b22213dd39d36a3e07b801 Mon Sep 17 00:00:00 2001 From: Jordan Murphy <35613487+jordan-d-murphy@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:05:32 -0700 Subject: [PATCH] Doc: fix PR01 docstring errors for pandas.CategoricalIndex.equals and pandas.CategoricalIndex.map (#57611) fix docstring errors for pandas.CategoricalIndex.equals and pandas.CategoricalIndex.map --- ci/code_checks.sh | 3 --- pandas/core/indexes/category.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 22c3a71812de7..875e328110aaf 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -414,8 +414,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (PR01)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=PR01 --ignore_functions \ - pandas.CategoricalIndex.equals\ - pandas.CategoricalIndex.map\ pandas.DataFrame.at_time\ pandas.DataFrame.backfill\ pandas.DataFrame.get\ @@ -1117,7 +1115,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.CategoricalIndex.as_ordered\ pandas.CategoricalIndex.as_unordered\ pandas.CategoricalIndex.codes\ - pandas.CategoricalIndex.equals\ pandas.CategoricalIndex.ordered\ pandas.DataFrame.__dataframe__\ pandas.DataFrame.__iter__\ diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 5e9d15812526f..3b04d95cb7cbd 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -276,12 +276,24 @@ def equals(self, other: object) -> bool: """ Determine if two CategoricalIndex objects contain the same elements. + The order and orderedness of elements matters. The categories matter, + but the order of the categories matters only when ``ordered=True``. + + Parameters + ---------- + other : object + The CategoricalIndex object to compare with. + Returns ------- bool ``True`` if two :class:`pandas.CategoricalIndex` objects have equal elements, ``False`` otherwise. + See Also + -------- + Categorical.equals : Returns True if categorical arrays are equal. + Examples -------- >>> ci = pd.CategoricalIndex(["a", "b", "c", "a", "b", "c"]) @@ -446,6 +458,9 @@ def map(self, mapper, na_action: Literal["ignore"] | None = None): ---------- mapper : function, dict, or Series Mapping correspondence. + na_action : {None, 'ignore'}, default 'ignore' + If 'ignore', propagate NaN values, without passing them to + the mapping correspondence. Returns -------