@@ -689,6 +689,41 @@ def _find_non_overlapping_monotonic_bounds(self, key):
689689 return start , stop
690690
691691 def get_loc (self , key , method = None ):
692+ """Get integer location, slice or boolean mask for requested label.
693+
694+ Parameters
695+ ----------
696+ key : label
697+ method : {None}, optional
698+ * default: matches where the label is within an interval only.
699+
700+ Returns
701+ -------
702+ loc : int if unique index, slice if monotonic index, else mask
703+
704+ Examples
705+ ---------
706+ >>> i1, i2 = pd.Interval(0, 1), pd.Interval(1, 2)
707+ >>> index = pd.IntervalIndex.from_intervals([i1, i2])
708+ >>> index.get_loc(1)
709+ 0
710+
711+ You can also supply an interval or an location for a point inside an
712+ interval.
713+
714+ >>> index.get_loc(pd.Interval(0, 2))
715+ array([0, 1], dtype=int64)
716+ >>> index.get_loc(1.5)
717+ 1
718+
719+ If a label is in several intervals, you get the locations of all the
720+ relevant intervals.
721+
722+ >>> i3 = pd.Interval(0, 2)
723+ >>> overlapping_index = pd.IntervalIndex.from_intervals([i2, i3])
724+ >>> overlapping_index.get_loc(1.5)
725+ array([0, 1], dtype=int64)
726+ """
692727 self ._check_method (method )
693728
694729 original_key = key
0 commit comments