diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 6a1b613eccb8b..6fb675069e81d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -73,27 +73,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Period.freq GL08" \ -i "pandas.Period.ordinal GL08" \ -i "pandas.RangeIndex.from_range PR01,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" \ - -i "pandas.Series.cat.remove_unused_categories PR01" \ - -i "pandas.Series.cat.rename_categories PR01,PR02" \ - -i "pandas.Series.cat.reorder_categories PR01,PR02" \ - -i "pandas.Series.cat.set_categories PR01,PR02" \ - -i "pandas.Series.dt.as_unit PR01,PR02" \ - -i "pandas.Series.dt.ceil PR01,PR02" \ - -i "pandas.Series.dt.day_name PR01,PR02" \ - -i "pandas.Series.dt.floor PR01,PR02" \ -i "pandas.Series.dt.freq GL08" \ - -i "pandas.Series.dt.month_name PR01,PR02" \ - -i "pandas.Series.dt.normalize PR01" \ - -i "pandas.Series.dt.round PR01,PR02" \ - -i "pandas.Series.dt.strftime PR01,PR02" \ - -i "pandas.Series.dt.to_period PR01,PR02" \ - -i "pandas.Series.dt.total_seconds PR01" \ - -i "pandas.Series.dt.tz_convert PR01,PR02" \ - -i "pandas.Series.dt.tz_localize PR01,PR02" \ -i "pandas.Series.dt.unit GL08" \ -i "pandas.Series.pad PR01,SA01" \ -i "pandas.Timedelta.max PR02" \ diff --git a/pandas/core/accessor.py b/pandas/core/accessor.py index d8463fda34caa..78684eacf2d66 100644 --- a/pandas/core/accessor.py +++ b/pandas/core/accessor.py @@ -7,6 +7,7 @@ from __future__ import annotations +import functools from typing import ( TYPE_CHECKING, final, @@ -117,12 +118,12 @@ def _setter(self, new_values): ) def _create_delegator_method(name: str): + method = getattr(delegate, accessor_mapping(name)) + + @functools.wraps(method) def f(self, *args, **kwargs): return self._delegate_method(name, *args, **kwargs) - f.__name__ = name - f.__doc__ = getattr(delegate, accessor_mapping(name)).__doc__ - return f for name in accessors: diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index a69e197df851d..0484ef89f61c2 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1155,6 +1155,12 @@ def rename_categories(self, new_categories) -> Self: """ Rename categories. + This method is commonly used to re-label or adjust the + category names in categorical data without changing the + underlying data. It is useful in situations where you want + to modify the labels used for clarity, consistency, + or readability. + Parameters ---------- new_categories : list-like, dict-like or callable @@ -1371,8 +1377,8 @@ def remove_categories(self, removals) -> Self: """ Remove the specified categories. - `removals` must be included in the old categories. Values which were in - the removed categories will be set to NaN + The ``removals`` argument must be a subset of the current categories. + Any values that were part of the removed categories will be set to NaN. Parameters ---------- @@ -1431,6 +1437,10 @@ def remove_unused_categories(self) -> Self: """ Remove categories which are not used. + This method is useful when working with datasets + that undergo dynamic changes where categories may no longer be + relevant, allowing to maintain a clean, efficient data structure. + Returns ------- Categorical