@@ -2350,8 +2350,7 @@ def get_level_values(self, level):
2350
2350
self ._validate_index_level (level )
2351
2351
return self
2352
2352
2353
- def get_indexer (self , target , method = None , limit = None , tolerance = None ):
2354
- """
2353
+ _index_shared_docs ['get_indexer' ] = """
2355
2354
Compute indexer and mask for new index given the current index. The
2356
2355
indexer should be then used as an input to ndarray.take to align the
2357
2356
current data to the new index.
@@ -2387,6 +2386,9 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):
2387
2386
positions matches the corresponding target values. Missing values
2388
2387
in the target are marked by -1.
2389
2388
"""
2389
+
2390
+ @Appender (_index_shared_docs ['get_indexer' ])
2391
+ def get_indexer (self , target , method = None , limit = None , tolerance = None ):
2390
2392
method = missing .clean_reindex_fill_method (method )
2391
2393
target = _ensure_index (target )
2392
2394
if tolerance is not None :
@@ -2496,11 +2498,28 @@ def _filter_indexer_tolerance(self, target, indexer, tolerance):
2496
2498
indexer = np .where (distance <= tolerance , indexer , - 1 )
2497
2499
return indexer
2498
2500
2501
+ _index_shared_docs ['get_indexer_non_unique' ] = """
2502
+ Compute indexer and mask for new index given the current index. The
2503
+ indexer should be then used as an input to ndarray.take to align the
2504
+ current data to the new index.
2505
+
2506
+ Parameters
2507
+ ----------
2508
+ target : Index
2509
+
2510
+ Returns
2511
+ -------
2512
+ indexer : ndarray of int
2513
+ Integers from 0 to n - 1 indicating that the index at these
2514
+ positions matches the corresponding target values. Missing values
2515
+ in the target are marked by -1.
2516
+ missing : ndarray of int
2517
+ An indexer into the target of the values not found.
2518
+ These correspond to the -1 in the indexer array
2519
+ """
2520
+
2521
+ @Appender (_index_shared_docs ['get_indexer_non_unique' ])
2499
2522
def get_indexer_non_unique (self , target ):
2500
- """ return an indexer suitable for taking from a non unique index
2501
- return the labels in the same order as the target, and
2502
- return a missing indexer into the target (missing are marked as -1
2503
- in the indexer); target must be an iterable """
2504
2523
target = _ensure_index (target )
2505
2524
pself , ptarget = self ._possibly_promote (target )
2506
2525
if pself is not self or ptarget is not target :
@@ -2516,7 +2535,10 @@ def get_indexer_non_unique(self, target):
2516
2535
return Index (indexer ), missing
2517
2536
2518
2537
def get_indexer_for (self , target , ** kwargs ):
2519
- """ guaranteed return of an indexer even when non-unique """
2538
+ """
2539
+ guaranteed return of an indexer even when non-unique
2540
+ This dispatches to get_indexer or get_indexer_nonunique as appropriate
2541
+ """
2520
2542
if self .is_unique :
2521
2543
return self .get_indexer (target , ** kwargs )
2522
2544
indexer , _ = self .get_indexer_non_unique (target , ** kwargs )
0 commit comments