9
9
from pandas ._libs .hashtable import duplicated_int64
10
10
from pandas ._libs .lib import no_default
11
11
from pandas ._typing import Label
12
- from pandas .util ._decorators import Appender , cache_readonly
12
+ from pandas .util ._decorators import Appender , cache_readonly , doc
13
13
14
14
from pandas .core .dtypes .common import (
15
15
ensure_platform_int ,
@@ -241,7 +241,7 @@ def _simple_new(cls, values: Categorical, name: Label = None):
241
241
242
242
# --------------------------------------------------------------------
243
243
244
- @Appender (Index ._shallow_copy . __doc__ )
244
+ @doc (Index ._shallow_copy )
245
245
def _shallow_copy (self , values = None , name : Label = no_default ):
246
246
if values is not None :
247
247
values = Categorical (values , dtype = self .dtype )
@@ -351,7 +351,7 @@ def _has_complex_internals(self) -> bool:
351
351
# used to avoid libreduction code paths, which raise or require conversion
352
352
return True
353
353
354
- @Appender (Index .__contains__ . __doc__ )
354
+ @doc (Index .__contains__ )
355
355
def __contains__ (self , key : Any ) -> bool :
356
356
# if key is a NaN, check if any NaN is in self.
357
357
if is_scalar (key ) and isna (key ):
@@ -360,7 +360,7 @@ def __contains__(self, key: Any) -> bool:
360
360
hash (key )
361
361
return contains (self , key , container = self ._engine )
362
362
363
- @Appender (Index .astype . __doc__ )
363
+ @doc (Index .astype )
364
364
def astype (self , dtype , copy = True ):
365
365
if is_interval_dtype (dtype ):
366
366
from pandas import IntervalIndex
@@ -379,7 +379,7 @@ def _isnan(self):
379
379
""" return if each value is nan"""
380
380
return self ._data .codes == - 1
381
381
382
- @Appender (Index .fillna . __doc__ )
382
+ @doc (Index .fillna )
383
383
def fillna (self , value , downcast = None ):
384
384
self ._assert_can_do_op (value )
385
385
return CategoricalIndex (self ._data .fillna (value ), name = self .name )
@@ -392,7 +392,7 @@ def _engine(self):
392
392
codes = self .codes
393
393
return self ._engine_type (lambda : codes , len (self ))
394
394
395
- @Appender (Index .unique . __doc__ )
395
+ @doc (Index .unique )
396
396
def unique (self , level = None ):
397
397
if level is not None :
398
398
self ._validate_index_level (level )
@@ -401,7 +401,7 @@ def unique(self, level=None):
401
401
# of result, not self.
402
402
return type (self )._simple_new (result , name = self .name )
403
403
404
- @Appender (Index .duplicated . __doc__ )
404
+ @doc (Index .duplicated )
405
405
def duplicated (self , keep = "first" ):
406
406
codes = self .codes .astype ("i8" )
407
407
return duplicated_int64 (codes , keep )
@@ -415,7 +415,7 @@ def _maybe_cast_indexer(self, key):
415
415
code = self .codes .dtype .type (code )
416
416
return code
417
417
418
- @Appender (Index .where . __doc__ )
418
+ @doc (Index .where )
419
419
def where (self , cond , other = None ):
420
420
# TODO: Investigate an alternative implementation with
421
421
# 1. copy the underlying Categorical
@@ -566,7 +566,7 @@ def get_indexer_non_unique(self, target):
566
566
indexer , missing = self ._engine .get_indexer_non_unique (codes )
567
567
return ensure_platform_int (indexer ), missing
568
568
569
- @Appender (Index ._convert_list_indexer . __doc__ )
569
+ @doc (Index ._convert_list_indexer )
570
570
def _convert_list_indexer (self , keyarr ):
571
571
# Return our indexer or raise if all of the values are not included in
572
572
# the categories
@@ -583,7 +583,7 @@ def _convert_list_indexer(self, keyarr):
583
583
584
584
return self .get_indexer (keyarr )
585
585
586
- @Appender (Index ._convert_arr_indexer . __doc__ )
586
+ @doc (Index ._convert_arr_indexer )
587
587
def _convert_arr_indexer (self , keyarr ):
588
588
keyarr = com .asarray_tuplesafe (keyarr )
589
589
@@ -592,7 +592,7 @@ def _convert_arr_indexer(self, keyarr):
592
592
593
593
return self ._shallow_copy (keyarr )
594
594
595
- @Appender (Index ._convert_index_indexer . __doc__ )
595
+ @doc (Index ._convert_index_indexer )
596
596
def _convert_index_indexer (self , keyarr ):
597
597
return self ._shallow_copy (keyarr )
598
598
@@ -605,7 +605,7 @@ def take_nd(self, *args, **kwargs):
605
605
)
606
606
return self .take (* args , ** kwargs )
607
607
608
- @Appender (Index ._maybe_cast_slice_bound . __doc__ )
608
+ @doc (Index ._maybe_cast_slice_bound )
609
609
def _maybe_cast_slice_bound (self , label , side , kind ):
610
610
if kind == "loc" :
611
611
return label
0 commit comments