7171 InvalidIndexError ,
7272)
7373from pandas .util ._decorators import (
74- Appender ,
74+ Appender
7575 cache_readonly ,
7676 doc ,
7777 set_module ,
@@ -1170,8 +1170,16 @@ def astype(self, dtype: Dtype, copy: bool = True):
11701170 result ._references .add_index_reference (result )
11711171 return result
11721172
1173- _index_shared_docs ["take" ] = """
1174- Return a new %(klass)s of the values selected by the indices.
1173+ def take (
1174+ self ,
1175+ indices ,
1176+ axis : Axis = 0 ,
1177+ allow_fill : bool = True ,
1178+ fill_value = None ,
1179+ ** kwargs ,
1180+ ) -> Self :
1181+ """
1182+ Return a new Index of the values selected by the indices.
11751183
11761184 For internal compatibility with numpy arrays.
11771185
@@ -1189,7 +1197,7 @@ def astype(self, dtype: Dtype, copy: bool = True):
11891197 :func:`numpy.take`.
11901198
11911199 * True: negative values in `indices` indicate
1192- missing values. These values are set to `fill_value`. Any other
1200+ missing values. These values are set to `fill_value`. Any
11931201 other negative values raise a ``ValueError``.
11941202
11951203 fill_value : scalar, default None
@@ -1215,16 +1223,6 @@ def astype(self, dtype: Dtype, copy: bool = True):
12151223 >>> idx.take([2, 2, 1, 2])
12161224 Index(['c', 'c', 'b', 'c'], dtype='str')
12171225 """
1218-
1219- @Appender (_index_shared_docs ["take" ] % _index_doc_kwargs )
1220- def take (
1221- self ,
1222- indices ,
1223- axis : Axis = 0 ,
1224- allow_fill : bool = True ,
1225- fill_value = None ,
1226- ** kwargs ,
1227- ) -> Self :
12281226 if kwargs :
12291227 nv .validate_take ((), kwargs )
12301228 if is_scalar (indices ):
@@ -1272,26 +1270,27 @@ def _maybe_disallow_fill(self, allow_fill: bool, fill_value, indices) -> bool:
12721270 allow_fill = False
12731271 return allow_fill
12741272
1275- _index_shared_docs ["repeat" ] = """
1276- Repeat elements of a %(klass)s.
1273+ def repeat (self , repeats , axis : None = None ) -> Self :
1274+ """
1275+ Repeat elements of a Index.
12771276
1278- Returns a new %(klass)s where each element of the current %(klass)s
1277+ Returns a new Index where each element of the current Index
12791278 is repeated consecutively a given number of times.
12801279
12811280 Parameters
12821281 ----------
12831282 repeats : int or array of ints
12841283 The number of repetitions for each element. This should be a
12851284 non-negative integer. Repeating 0 times will return an empty
1286- %(klass)s .
1285+ Index .
12871286 axis : None
12881287 Must be ``None``. Has no effect but is accepted for compatibility
12891288 with numpy.
12901289
12911290 Returns
12921291 -------
1293- %(klass)s
1294- Newly created %(klass)s with repeated elements.
1292+ Index
1293+ Newly created Index with repeated elements.
12951294
12961295 See Also
12971296 --------
@@ -1308,9 +1307,6 @@ def _maybe_disallow_fill(self, allow_fill: bool, fill_value, indices) -> bool:
13081307 >>> idx.repeat([1, 2, 3])
13091308 Index(['a', 'b', 'b', 'c', 'c', 'c'], dtype='object')
13101309 """
1311-
1312- @Appender (_index_shared_docs ["repeat" ] % _index_doc_kwargs )
1313- def repeat (self , repeats , axis : None = None ) -> Self :
13141310 repeats = ensure_platform_int (repeats )
13151311 nv .validate_repeat ((), {"axis" : axis })
13161312 res_values = self ._values .repeat (repeats )
@@ -5940,15 +5936,18 @@ def _should_fallback_to_positional(self) -> bool:
59405936 "complex" ,
59415937 }
59425938
5943- _index_shared_docs ["get_indexer_non_unique" ] = """
5939+ def get_indexer_non_unique (
5940+ self , target
5941+ ) -> tuple [npt .NDArray [np .intp ], npt .NDArray [np .intp ]]:
5942+ """
59445943 Compute indexer and mask for new index given the current index.
59455944
59465945 The indexer should be then used as an input to ndarray.take to align the
59475946 current data to the new index.
59485947
59495948 Parameters
59505949 ----------
5951- target : %(target_klass)s
5950+ target : Index
59525951 An iterable containing the values to be used for computing indexer.
59535952
59545953 Returns
@@ -5992,11 +5991,6 @@ def _should_fallback_to_positional(self) -> bool:
59925991 >>> index.get_indexer_non_unique(['f', 'b', 's'])
59935992 (array([-1, 1, 3, 4, -1]), array([0, 2]))
59945993 """
5995-
5996- @Appender (_index_shared_docs ["get_indexer_non_unique" ] % _index_doc_kwargs )
5997- def get_indexer_non_unique (
5998- self , target
5999- ) -> tuple [npt .NDArray [np .intp ], npt .NDArray [np .intp ]]:
60005994 target = self ._maybe_cast_listlike_indexer (target )
60015995
60025996 if not self ._should_compare (target ) and not self ._should_partial_index (target ):
0 commit comments