Skip to content

DOC: fix PR01,PR02 for pandas.Series.cat.add_categories #59676

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
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.RangeIndex.start SA01" \
-i "pandas.RangeIndex.step SA01" \
-i "pandas.RangeIndex.stop SA01" \
-i "pandas.Series.cat.add_categories PR01,PR02" \
-i "pandas.Series.cat.as_ordered PR01" \
-i "pandas.Series.cat.as_unordered PR01" \
-i "pandas.Series.cat.remove_categories PR01,PR02" \
Expand Down
18 changes: 16 additions & 2 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,11 +1302,25 @@ def add_categories(self, new_categories) -> Self:
"""
Add new categories.

`new_categories` will be included at the last/highest place in the
categories and will be unused directly after this call.
`new_categories` will be included at the last/highest place in the categories
and will be unused directly after this call. This method is useful when
working with categorical data that needs to be updated or extended with new
categories over time. Adding categories in this way avoids the need to
redefine the entire set of categories, which can be especially helpful in
scenarios where the categorical data is large or frequently updated. New
categories are added to the end of the list of categories, and their presence
will not affect the current categorical values directly until they are
explicitly used.

Parameters
----------
*args : iterable, optional
Positional arguments passed into `func`.
**kwargs : dict, optional
A dictionary of keyword arguments passed into `func`.

Attributes
----------
new_categories : category or list-like of category
The new categories to be included.

Expand Down
Loading