pandas 1.4.2

ParametersReturns
get_loc(self, key, method: 'str | None' = None, tolerance=None) -> 'int | slice | np.ndarray'

Parameters

key : label
method : {None}, optional
  • default: matches where the label is within an interval only.

Returns

int if unique index, slice if monotonic index, else mask

Get integer location, slice or boolean mask for requested label.

Examples

This example is valid syntax, but we were not able to check execution
>>> i1, i2 = pd.Interval(0, 1), pd.Interval(1, 2)
... index = pd.IntervalIndex([i1, i2])
... index.get_loc(1) 0

You can also supply a point inside an interval.

This example is valid syntax, but we were not able to check execution
>>> index.get_loc(1.5)
1

If a label is in several intervals, you get the locations of all the relevant intervals.

This example is valid syntax, but we were not able to check execution
>>> i3 = pd.Interval(0, 2)
... overlapping_index = pd.IntervalIndex([i1, i2, i3])
... overlapping_index.get_loc(0.5) array([ True, False, True])

Only exact matches will be returned if an interval is provided.

This example is valid syntax, but we were not able to check execution
>>> index.get_loc(pd.Interval(0, 1))
0
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/indexes/interval.py#575
type: <class 'function'>
Commit: