pandas.IntervalIndex.get_loc
-
IntervalIndex.get_loc(key, method=None)
[source] -
Get integer location, slice or boolean mask for requested label.
Parameters: -
key : label
method : {None}, optional
- default: matches where the label is within an interval only.
Returns: -
loc : int if unique index, slice if monotonic index, else mask
Examples
>>> i1, i2 = pd.Interval(0, 1), pd.Interval(1, 2) >>> index = pd.IntervalIndex([i1, i2]) >>> index.get_loc(1) 0
You can also supply an interval or an location for a point inside an interval.
>>> index.get_loc(pd.Interval(0, 2)) array([0, 1], dtype=int64) >>> index.get_loc(1.5) 1
If a label is in several intervals, you get the locations of all the relevant intervals.
>>> i3 = pd.Interval(0, 2) >>> overlapping_index = pd.IntervalIndex([i2, i3]) >>> overlapping_index.get_loc(1.5) array([0, 1], dtype=int64)
-
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.IntervalIndex.get_loc.html