Skip to content

ES01 Extended Summaries for Categorical #57540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Partially validate docstrings (ES01)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=ES01 --ignore_functions \
pandas.Categorical.__array__\
pandas.Categorical.as_ordered\
pandas.Categorical.as_unordered\
pandas.Categorical.dtype\
pandas.Categorical.ordered\
pandas.Categorical.remove_unused_categories\
pandas.Categorical.rename_categories\
pandas.CategoricalDtype\
pandas.CategoricalDtype.categories\
pandas.CategoricalDtype.ordered\
Expand Down
30 changes: 30 additions & 0 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ def ordered(self) -> Ordered:
"""
Whether the categories have an ordered relationship.

Returns whether the categories can be ordered.
Ordered categories can be sorted, and operations such
as .min() and .max() make sense and do not raise a
TypeError.

Examples
--------
For :class:`pandas.Series`:
Expand Down Expand Up @@ -986,6 +991,11 @@ def as_ordered(self) -> Self:
"""
Set the Categorical to be ordered.

Creates a new object that contains the same categories
as the input, but is ordered. This means that the
categories can be sorted, and .min() and .max() operations
do not raise a TypeError.

Returns
-------
Categorical
Expand Down Expand Up @@ -1017,6 +1027,11 @@ def as_unordered(self) -> Self:
"""
Set the Categorical to be unordered.

Creates a new object that contains the same categories
as the input, but is not ordered. This means that the
categories cannot be sorted, and .min() and .max()
operations raise a TypeError.

Returns
-------
Categorical
Expand Down Expand Up @@ -1160,6 +1175,9 @@ def rename_categories(self, new_categories) -> Self:
"""
Rename categories.

Renames the categories using an array, a map, or
a lambda function.

Parameters
----------
new_categories : list-like, dict-like or callable
Expand Down Expand Up @@ -1436,6 +1454,11 @@ def remove_unused_categories(self) -> Self:
"""
Remove categories which are not used.

Categorical arrays are mutable, and as such
it is possible that some of the initial categories
are no longer used down the line. This removes
original categories that are no longer in use.

Returns
-------
Categorical
Expand Down Expand Up @@ -1663,6 +1686,13 @@ def __array__(self, dtype: NpDtype | None = None) -> np.ndarray:
"""
The numpy array interface.

This defines the __array__ method within a Pandas Categorical
class, making it compatible with numpy arrays.

The method returns a numpy array representation of the categorical
data. It accepts an optional dtype parameter, allowing the user
to specify the data type of the resulting numpy array.

Parameters
----------
dtype : np.dtype or None
Expand Down