Skip to content

Commit 6651d7e

Browse files
DOC: fix PR01,PR02 for pandas.Series.cat.add_categories
1 parent 94a7c14 commit 6651d7e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8282
-i "pandas.RangeIndex.start SA01" \
8383
-i "pandas.RangeIndex.step SA01" \
8484
-i "pandas.RangeIndex.stop SA01" \
85-
-i "pandas.Series.cat.add_categories PR01,PR02" \
8685
-i "pandas.Series.cat.as_ordered PR01" \
8786
-i "pandas.Series.cat.as_unordered PR01" \
8887
-i "pandas.Series.cat.remove_categories PR01,PR02" \

pandas/core/arrays/categorical.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,11 +1302,25 @@ def add_categories(self, new_categories) -> Self:
13021302
"""
13031303
Add new categories.
13041304
1305-
`new_categories` will be included at the last/highest place in the
1306-
categories and will be unused directly after this call.
1305+
`new_categories` will be included at the last/highest place in the categories
1306+
and will be unused directly after this call. This method is useful when
1307+
working with categorical data that needs to be updated or extended with new
1308+
categories over time. Adding categories in this way avoids the need to
1309+
redefine the entire set of categories, which can be especially helpful in
1310+
scenarios where the categorical data is large or frequently updated. New
1311+
categories are added to the end of the list of categories, and their presence
1312+
will not affect the current categorical values directly until they are
1313+
explicitly used.
13071314
13081315
Parameters
13091316
----------
1317+
*args : iterable, optional
1318+
Positional arguments passed into `func`.
1319+
**kwargs : dict, optional
1320+
A dictionary of keyword arguments passed into `func`.
1321+
1322+
Attributes
1323+
----------
13101324
new_categories : category or list-like of category
13111325
The new categories to be included.
13121326

0 commit comments

Comments
 (0)