4
4
5
5
from pandas ._libs import index as libindex , lib
6
6
from pandas ._typing import Dtype , Label
7
- from pandas .util ._decorators import Appender , cache_readonly
7
+ from pandas .util ._decorators import cache_readonly , doc
8
8
9
9
from pandas .core .dtypes .cast import astype_nansafe
10
10
from pandas .core .dtypes .common import (
@@ -95,14 +95,14 @@ def _validate_dtype(cls, dtype: Dtype) -> None:
95
95
f"Incorrect `dtype` passed: expected { expected } , received { dtype } "
96
96
)
97
97
98
- @Appender (Index ._maybe_cast_slice_bound . __doc__ )
98
+ @doc (Index ._maybe_cast_slice_bound )
99
99
def _maybe_cast_slice_bound (self , label , side , kind ):
100
100
assert kind in ["loc" , "getitem" , None ]
101
101
102
102
# we will try to coerce to integers
103
103
return self ._maybe_cast_indexer (label )
104
104
105
- @Appender (Index ._shallow_copy . __doc__ )
105
+ @doc (Index ._shallow_copy )
106
106
def _shallow_copy (self , values = None , name : Label = lib .no_default ):
107
107
if values is not None and not self ._can_hold_na and values .dtype .kind == "f" :
108
108
name = self .name if name is lib .no_default else name
@@ -158,7 +158,7 @@ def is_all_dates(self) -> bool:
158
158
"""
159
159
return False
160
160
161
- @Appender (Index .insert . __doc__ )
161
+ @doc (Index .insert )
162
162
def insert (self , loc : int , item ):
163
163
# treat NA values as nans:
164
164
if is_scalar (item ) and isna (item ):
@@ -295,7 +295,7 @@ class UInt64Index(IntegerIndex):
295
295
_engine_type = libindex .UInt64Engine
296
296
_default_dtype = np .dtype (np .uint64 )
297
297
298
- @Appender (Index ._convert_arr_indexer . __doc__ )
298
+ @doc (Index ._convert_arr_indexer )
299
299
def _convert_arr_indexer (self , keyarr ):
300
300
# Cast the indexer to uint64 if possible so that the values returned
301
301
# from indexing are also uint64.
@@ -307,7 +307,7 @@ def _convert_arr_indexer(self, keyarr):
307
307
308
308
return com .asarray_tuplesafe (keyarr , dtype = dtype )
309
309
310
- @Appender (Index ._convert_index_indexer . __doc__ )
310
+ @doc (Index ._convert_index_indexer )
311
311
def _convert_index_indexer (self , keyarr ):
312
312
# Cast the indexer to uint64 if possible so
313
313
# that the values returned from indexing are
@@ -357,7 +357,7 @@ def inferred_type(self) -> str:
357
357
"""
358
358
return "floating"
359
359
360
- @Appender (Index .astype . __doc__ )
360
+ @doc (Index .astype )
361
361
def astype (self , dtype , copy = True ):
362
362
dtype = pandas_dtype (dtype )
363
363
if needs_i8_conversion (dtype ):
@@ -375,11 +375,11 @@ def astype(self, dtype, copy=True):
375
375
# ----------------------------------------------------------------
376
376
# Indexing Methods
377
377
378
- @Appender (Index ._should_fallback_to_positional . __doc__ )
378
+ @doc (Index ._should_fallback_to_positional )
379
379
def _should_fallback_to_positional (self ):
380
380
return False
381
381
382
- @Appender (Index ._convert_slice_indexer . __doc__ )
382
+ @doc (Index ._convert_slice_indexer )
383
383
def _convert_slice_indexer (self , key : slice , kind : str ):
384
384
assert kind in ["loc" , "getitem" ]
385
385
@@ -433,7 +433,7 @@ def __contains__(self, other: Any) -> bool:
433
433
434
434
return is_float (other ) and np .isnan (other ) and self .hasnans
435
435
436
- @Appender (Index .get_loc . __doc__ )
436
+ @doc (Index .get_loc )
437
437
def get_loc (self , key , method = None , tolerance = None ):
438
438
if is_bool (key ):
439
439
# Catch this to avoid accidentally casting to 1.0
@@ -453,7 +453,7 @@ def get_loc(self, key, method=None, tolerance=None):
453
453
def is_unique (self ) -> bool :
454
454
return super ().is_unique and self ._nan_idxs .size < 2
455
455
456
- @Appender (Index .isin . __doc__ )
456
+ @doc (Index .isin )
457
457
def isin (self , values , level = None ):
458
458
if level is not None :
459
459
self ._validate_index_level (level )
0 commit comments