pandas 1.4.2

NotesParametersReturnsBackRef
get_loc(self, key, method=None)

The location is returned as an integer/slice or boolean mask.

Notes

The key cannot be a slice, list of same-level labels, a boolean mask, or a sequence of such. If you want to use those, use MultiIndex.get_locs instead.

Parameters

key : label or tuple of labels (one for each level)
method : None

Returns

loc : int, slice object or boolean mask

If the key is past the lexsort depth, the return may be a boolean mask array, otherwise it is always a slice or int.

Get location for a label or a tuple of labels.

See Also

Index.get_loc

The get_loc method for (single-level) index.

MultiIndex.get_locs

Get location for a label/slice/list/mask or a sequence of such.

MultiIndex.slice_locs

Get slice location given start label(s) and end label(s).

Examples

This example is valid syntax, but we were not able to check execution
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')])
This example is valid syntax, but we were not able to check execution
>>> mi.get_loc('b')
slice(1, 3, None)
This example is valid syntax, but we were not able to check execution
>>> mi.get_loc(('b', 'e'))
1
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.indexes.multi.MultiIndex.get_slice_bound pandas.core.indexes.multi.MultiIndex.get_loc_level pandas.core.indexes.multi.MultiIndex.slice_locs pandas.core.indexes.multi.MultiIndex.get_locs

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/multi.py#2804
type: <class 'function'>
Commit: