44
55from pandas ._libs import index as libindex , lib
66from pandas ._typing import Dtype , Label
7- from pandas .util ._decorators import Appender , cache_readonly
7+ from pandas .util ._decorators import cache_readonly , doc
88
99from pandas .core .dtypes .cast import astype_nansafe
1010from pandas .core .dtypes .common import (
@@ -95,14 +95,14 @@ def _validate_dtype(cls, dtype: Dtype) -> None:
9595 f"Incorrect `dtype` passed: expected { expected } , received { dtype } "
9696 )
9797
98- @Appender (Index ._maybe_cast_slice_bound . __doc__ )
98+ @doc (Index ._maybe_cast_slice_bound )
9999 def _maybe_cast_slice_bound (self , label , side , kind ):
100100 assert kind in ["loc" , "getitem" , None ]
101101
102102 # we will try to coerce to integers
103103 return self ._maybe_cast_indexer (label )
104104
105- @Appender (Index ._shallow_copy . __doc__ )
105+ @doc (Index ._shallow_copy )
106106 def _shallow_copy (self , values = None , name : Label = lib .no_default ):
107107 if values is not None and not self ._can_hold_na and values .dtype .kind == "f" :
108108 name = self .name if name is lib .no_default else name
@@ -158,7 +158,7 @@ def is_all_dates(self) -> bool:
158158 """
159159 return False
160160
161- @Appender (Index .insert . __doc__ )
161+ @doc (Index .insert )
162162 def insert (self , loc : int , item ):
163163 # treat NA values as nans:
164164 if is_scalar (item ) and isna (item ):
@@ -295,7 +295,7 @@ class UInt64Index(IntegerIndex):
295295 _engine_type = libindex .UInt64Engine
296296 _default_dtype = np .dtype (np .uint64 )
297297
298- @Appender (Index ._convert_arr_indexer . __doc__ )
298+ @doc (Index ._convert_arr_indexer )
299299 def _convert_arr_indexer (self , keyarr ):
300300 # Cast the indexer to uint64 if possible so that the values returned
301301 # from indexing are also uint64.
@@ -307,7 +307,7 @@ def _convert_arr_indexer(self, keyarr):
307307
308308 return com .asarray_tuplesafe (keyarr , dtype = dtype )
309309
310- @Appender (Index ._convert_index_indexer . __doc__ )
310+ @doc (Index ._convert_index_indexer )
311311 def _convert_index_indexer (self , keyarr ):
312312 # Cast the indexer to uint64 if possible so
313313 # that the values returned from indexing are
@@ -357,7 +357,7 @@ def inferred_type(self) -> str:
357357 """
358358 return "floating"
359359
360- @Appender (Index .astype . __doc__ )
360+ @doc (Index .astype )
361361 def astype (self , dtype , copy = True ):
362362 dtype = pandas_dtype (dtype )
363363 if needs_i8_conversion (dtype ):
@@ -375,11 +375,11 @@ def astype(self, dtype, copy=True):
375375 # ----------------------------------------------------------------
376376 # Indexing Methods
377377
378- @Appender (Index ._should_fallback_to_positional . __doc__ )
378+ @doc (Index ._should_fallback_to_positional )
379379 def _should_fallback_to_positional (self ):
380380 return False
381381
382- @Appender (Index ._convert_slice_indexer . __doc__ )
382+ @doc (Index ._convert_slice_indexer )
383383 def _convert_slice_indexer (self , key : slice , kind : str ):
384384 assert kind in ["loc" , "getitem" ]
385385
@@ -433,7 +433,7 @@ def __contains__(self, other: Any) -> bool:
433433
434434 return is_float (other ) and np .isnan (other ) and self .hasnans
435435
436- @Appender (Index .get_loc . __doc__ )
436+ @doc (Index .get_loc )
437437 def get_loc (self , key , method = None , tolerance = None ):
438438 if is_bool (key ):
439439 # Catch this to avoid accidentally casting to 1.0
@@ -453,7 +453,7 @@ def get_loc(self, key, method=None, tolerance=None):
453453 def is_unique (self ) -> bool :
454454 return super ().is_unique and self ._nan_idxs .size < 2
455455
456- @Appender (Index .isin . __doc__ )
456+ @doc (Index .isin )
457457 def isin (self , values , level = None ):
458458 if level is not None :
459459 self ._validate_index_level (level )
0 commit comments