Skip to content

Commit 809f920

Browse files
authored
CLN: update Appender to doc decorator with case __doc__ (#33112)
1 parent 7673357 commit 809f920

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

pandas/core/groupby/generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from pandas._libs import Timestamp, lib
3333
from pandas._typing import FrameOrSeries
34-
from pandas.util._decorators import Appender, Substitution
34+
from pandas.util._decorators import Appender, Substitution, doc
3535

3636
from pandas.core.dtypes.cast import (
3737
maybe_cast_result,
@@ -633,7 +633,7 @@ def nunique(self, dropna: bool = True) -> Series:
633633
result = Series(res, index=ri, name=self._selection_name)
634634
return self._reindex_output(result, fill_value=0)
635635

636-
@Appender(Series.describe.__doc__)
636+
@doc(Series.describe)
637637
def describe(self, **kwargs):
638638
result = self.apply(lambda x: x.describe(**kwargs))
639639
if self.axis == 1:

pandas/core/groupby/groupby.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class providing the base-class of operations.
3737
from pandas.compat import set_function_name
3838
from pandas.compat.numpy import function as nv
3939
from pandas.errors import AbstractMethodError
40-
from pandas.util._decorators import Appender, Substitution, cache_readonly
40+
from pandas.util._decorators import Appender, Substitution, cache_readonly, doc
4141

4242
from pandas.core.dtypes.cast import maybe_cast_result
4343
from pandas.core.dtypes.common import (
@@ -1420,7 +1420,7 @@ def ohlc(self) -> DataFrame:
14201420
"""
14211421
return self._apply_to_column_groupbys(lambda x: x._cython_agg_general("ohlc"))
14221422

1423-
@Appender(DataFrame.describe.__doc__)
1423+
@doc(DataFrame.describe)
14241424
def describe(self, **kwargs):
14251425
with _group_selection_context(self):
14261426
result = self.apply(lambda x: x.describe(**kwargs))
@@ -2509,7 +2509,7 @@ def _reindex_output(
25092509
GroupBy._add_numeric_operations()
25102510

25112511

2512-
@Appender(GroupBy.__doc__)
2512+
@doc(GroupBy)
25132513
def get_groupby(
25142514
obj: NDFrame,
25152515
by: Optional[_KeysArgType] = None,

pandas/core/indexes/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from pandas._typing import Label
1616
from pandas.compat import set_function_name
1717
from pandas.compat.numpy import function as nv
18-
from pandas.util._decorators import Appender, Substitution, cache_readonly
18+
from pandas.util._decorators import Appender, Substitution, cache_readonly, doc
1919

2020
from pandas.core.dtypes import concat as _concat
2121
from pandas.core.dtypes.cast import (
@@ -3835,7 +3835,7 @@ def values(self) -> np.ndarray:
38353835
return self._data.view(np.ndarray)
38363836

38373837
@cache_readonly
3838-
@Appender(IndexOpsMixin.array.__doc__) # type: ignore
3838+
@doc(IndexOpsMixin.array) # type: ignore
38393839
def array(self) -> ExtensionArray:
38403840
array = self._data
38413841
if isinstance(array, np.ndarray):
@@ -3876,7 +3876,7 @@ def _get_engine_target(self) -> np.ndarray:
38763876
"""
38773877
return self._values
38783878

3879-
@Appender(IndexOpsMixin.memory_usage.__doc__)
3879+
@doc(IndexOpsMixin.memory_usage)
38803880
def memory_usage(self, deep: bool = False) -> int:
38813881
result = super().memory_usage(deep=deep)
38823882

pandas/core/indexes/category.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pandas._libs.hashtable import duplicated_int64
1010
from pandas._libs.lib import no_default
1111
from pandas._typing import Label
12-
from pandas.util._decorators import Appender, cache_readonly
12+
from pandas.util._decorators import Appender, cache_readonly, doc
1313

1414
from pandas.core.dtypes.common import (
1515
ensure_platform_int,
@@ -241,7 +241,7 @@ def _simple_new(cls, values: Categorical, name: Label = None):
241241

242242
# --------------------------------------------------------------------
243243

244-
@Appender(Index._shallow_copy.__doc__)
244+
@doc(Index._shallow_copy)
245245
def _shallow_copy(self, values=None, name: Label = no_default):
246246
name = self.name if name is no_default else name
247247

@@ -354,7 +354,7 @@ def _has_complex_internals(self) -> bool:
354354
# used to avoid libreduction code paths, which raise or require conversion
355355
return True
356356

357-
@Appender(Index.__contains__.__doc__)
357+
@doc(Index.__contains__)
358358
def __contains__(self, key: Any) -> bool:
359359
# if key is a NaN, check if any NaN is in self.
360360
if is_scalar(key) and isna(key):
@@ -363,7 +363,7 @@ def __contains__(self, key: Any) -> bool:
363363
hash(key)
364364
return contains(self, key, container=self._engine)
365365

366-
@Appender(Index.astype.__doc__)
366+
@doc(Index.astype)
367367
def astype(self, dtype, copy=True):
368368
if is_interval_dtype(dtype):
369369
from pandas import IntervalIndex
@@ -382,7 +382,7 @@ def _isnan(self):
382382
""" return if each value is nan"""
383383
return self._data.codes == -1
384384

385-
@Appender(Index.fillna.__doc__)
385+
@doc(Index.fillna)
386386
def fillna(self, value, downcast=None):
387387
self._assert_can_do_op(value)
388388
return CategoricalIndex(self._data.fillna(value), name=self.name)
@@ -395,7 +395,7 @@ def _engine(self):
395395
codes = self.codes
396396
return self._engine_type(lambda: codes, len(self))
397397

398-
@Appender(Index.unique.__doc__)
398+
@doc(Index.unique)
399399
def unique(self, level=None):
400400
if level is not None:
401401
self._validate_index_level(level)
@@ -404,7 +404,7 @@ def unique(self, level=None):
404404
# of result, not self.
405405
return type(self)._simple_new(result, name=self.name)
406406

407-
@Appender(Index.duplicated.__doc__)
407+
@doc(Index.duplicated)
408408
def duplicated(self, keep="first"):
409409
codes = self.codes.astype("i8")
410410
return duplicated_int64(codes, keep)
@@ -418,7 +418,7 @@ def _maybe_cast_indexer(self, key):
418418
code = self.codes.dtype.type(code)
419419
return code
420420

421-
@Appender(Index.where.__doc__)
421+
@doc(Index.where)
422422
def where(self, cond, other=None):
423423
# TODO: Investigate an alternative implementation with
424424
# 1. copy the underlying Categorical
@@ -569,7 +569,7 @@ def get_indexer_non_unique(self, target):
569569
indexer, missing = self._engine.get_indexer_non_unique(codes)
570570
return ensure_platform_int(indexer), missing
571571

572-
@Appender(Index._convert_list_indexer.__doc__)
572+
@doc(Index._convert_list_indexer)
573573
def _convert_list_indexer(self, keyarr):
574574
# Return our indexer or raise if all of the values are not included in
575575
# the categories
@@ -586,7 +586,7 @@ def _convert_list_indexer(self, keyarr):
586586

587587
return self.get_indexer(keyarr)
588588

589-
@Appender(Index._convert_arr_indexer.__doc__)
589+
@doc(Index._convert_arr_indexer)
590590
def _convert_arr_indexer(self, keyarr):
591591
keyarr = com.asarray_tuplesafe(keyarr)
592592

@@ -595,7 +595,7 @@ def _convert_arr_indexer(self, keyarr):
595595

596596
return self._shallow_copy(keyarr)
597597

598-
@Appender(Index._convert_index_indexer.__doc__)
598+
@doc(Index._convert_index_indexer)
599599
def _convert_index_indexer(self, keyarr):
600600
return self._shallow_copy(keyarr)
601601

@@ -608,7 +608,7 @@ def take_nd(self, *args, **kwargs):
608608
)
609609
return self.take(*args, **kwargs)
610610

611-
@Appender(Index._maybe_cast_slice_bound.__doc__)
611+
@doc(Index._maybe_cast_slice_bound)
612612
def _maybe_cast_slice_bound(self, label, side, kind):
613613
if kind == "loc":
614614
return label

0 commit comments

Comments
 (0)