@@ -2441,7 +2441,51 @@ def reindex(self, target, method=None, level=None, limit=None, tolerance=None):
2441
2441
2442
2442
return target , indexer
2443
2443
2444
- def get_slice_bound (self , label , side , kind ):
2444
+ def get_slice_bound (self , label , side , kind ) -> int :
2445
+ """
2446
+ For an ordered MultiIndex, compute slice bound
2447
+ that corresponds to given label.
2448
+
2449
+ Returns leftmost (one-past-the-rightmost if `side=='right') position
2450
+ of given label.
2451
+
2452
+ Parameters
2453
+ ----------
2454
+ label : object or tuple of objects
2455
+ side : {'left', 'right'}
2456
+ kind : {'ix', 'loc', 'getitem'}
2457
+
2458
+ Returns
2459
+ -------
2460
+ int
2461
+ Index of label.
2462
+
2463
+ Notes
2464
+ -----
2465
+ This method only works if level 0 index of the MultiIndex is lexsorted.
2466
+
2467
+ Examples
2468
+ --------
2469
+ >>> mi = pd.MultiIndex.from_arrays([list('abbc'), list('gefd')])
2470
+
2471
+ Get the locations from the leftmost 'b' in the first level
2472
+ until the end of the multiindex:
2473
+
2474
+ >>> mi.get_slice_bound('b', side="left", kind="ix")
2475
+ 1
2476
+
2477
+ Like above, but if you get the locations from the rightmost
2478
+ 'b' in the first level and 'f' in the second level:
2479
+
2480
+ >>> mi.get_slice_bound(('b','f'), side="right", kind="ix")
2481
+ 3
2482
+
2483
+ See Also
2484
+ --------
2485
+ MultiIndex.get_loc : Get location for a label or a tuple of labels.
2486
+ MultiIndex.get_locs : Get location for a label/slice/list/mask or a
2487
+ sequence of such.
2488
+ """
2445
2489
2446
2490
if not isinstance (label , tuple ):
2447
2491
label = (label ,)
0 commit comments