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
name = self .name if name is no_default else name
247
247
@@ -354,7 +354,7 @@ def _has_complex_internals(self) -> bool:
354
354
# used to avoid libreduction code paths, which raise or require conversion
355
355
return True
356
356
357
- @Appender (Index .__contains__ . __doc__ )
357
+ @doc (Index .__contains__ )
358
358
def __contains__ (self , key : Any ) -> bool :
359
359
# if key is a NaN, check if any NaN is in self.
360
360
if is_scalar (key ) and isna (key ):
@@ -363,7 +363,7 @@ def __contains__(self, key: Any) -> bool:
363
363
hash (key )
364
364
return contains (self , key , container = self ._engine )
365
365
366
- @Appender (Index .astype . __doc__ )
366
+ @doc (Index .astype )
367
367
def astype (self , dtype , copy = True ):
368
368
if is_interval_dtype (dtype ):
369
369
from pandas import IntervalIndex
@@ -382,7 +382,7 @@ def _isnan(self):
382
382
""" return if each value is nan"""
383
383
return self ._data .codes == - 1
384
384
385
- @Appender (Index .fillna . __doc__ )
385
+ @doc (Index .fillna )
386
386
def fillna (self , value , downcast = None ):
387
387
self ._assert_can_do_op (value )
388
388
return CategoricalIndex (self ._data .fillna (value ), name = self .name )
@@ -395,7 +395,7 @@ def _engine(self):
395
395
codes = self .codes
396
396
return self ._engine_type (lambda : codes , len (self ))
397
397
398
- @Appender (Index .unique . __doc__ )
398
+ @doc (Index .unique )
399
399
def unique (self , level = None ):
400
400
if level is not None :
401
401
self ._validate_index_level (level )
@@ -404,7 +404,7 @@ def unique(self, level=None):
404
404
# of result, not self.
405
405
return type (self )._simple_new (result , name = self .name )
406
406
407
- @Appender (Index .duplicated . __doc__ )
407
+ @doc (Index .duplicated )
408
408
def duplicated (self , keep = "first" ):
409
409
codes = self .codes .astype ("i8" )
410
410
return duplicated_int64 (codes , keep )
@@ -418,7 +418,7 @@ def _maybe_cast_indexer(self, key):
418
418
code = self .codes .dtype .type (code )
419
419
return code
420
420
421
- @Appender (Index .where . __doc__ )
421
+ @doc (Index .where )
422
422
def where (self , cond , other = None ):
423
423
# TODO: Investigate an alternative implementation with
424
424
# 1. copy the underlying Categorical
@@ -569,7 +569,7 @@ def get_indexer_non_unique(self, target):
569
569
indexer , missing = self ._engine .get_indexer_non_unique (codes )
570
570
return ensure_platform_int (indexer ), missing
571
571
572
- @Appender (Index ._convert_list_indexer . __doc__ )
572
+ @doc (Index ._convert_list_indexer )
573
573
def _convert_list_indexer (self , keyarr ):
574
574
# Return our indexer or raise if all of the values are not included in
575
575
# the categories
@@ -586,7 +586,7 @@ def _convert_list_indexer(self, keyarr):
586
586
587
587
return self .get_indexer (keyarr )
588
588
589
- @Appender (Index ._convert_arr_indexer . __doc__ )
589
+ @doc (Index ._convert_arr_indexer )
590
590
def _convert_arr_indexer (self , keyarr ):
591
591
keyarr = com .asarray_tuplesafe (keyarr )
592
592
@@ -595,7 +595,7 @@ def _convert_arr_indexer(self, keyarr):
595
595
596
596
return self ._shallow_copy (keyarr )
597
597
598
- @Appender (Index ._convert_index_indexer . __doc__ )
598
+ @doc (Index ._convert_index_indexer )
599
599
def _convert_index_indexer (self , keyarr ):
600
600
return self ._shallow_copy (keyarr )
601
601
@@ -608,7 +608,7 @@ def take_nd(self, *args, **kwargs):
608
608
)
609
609
return self .take (* args , ** kwargs )
610
610
611
- @Appender (Index ._maybe_cast_slice_bound . __doc__ )
611
+ @doc (Index ._maybe_cast_slice_bound )
612
612
def _maybe_cast_slice_bound (self , label , side , kind ):
613
613
if kind == "loc" :
614
614
return label
0 commit comments