99from pandas ._libs .hashtable import duplicated_int64
1010from pandas ._libs .lib import no_default
1111from pandas ._typing import Label
12- from pandas .util ._decorators import Appender , cache_readonly
12+ from pandas .util ._decorators import Appender , cache_readonly , doc
1313
1414from 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