hipdf.MultiIndex.get_loc#
21 min read time
Applies to Linux
- MultiIndex.get_loc(key, method=None, tolerance=None)#
Get location for a label or a tuple of labels.
The location is returned as an integer/slice or boolean mask.
Parameters#
key : label or tuple of labels (one for each level) method : None
Returns#
- locint, slice object or boolean mask
If index is unique, search result is unique, return a single int.
If index is monotonic, index is returned as a slice object.
Otherwise, cudf attempts a best effort to convert the search result into a slice object, and will return a boolean mask if failed to do so. Notice this can deviate from Pandas behavior in some situations.
Examples#
>>> import cudf >>> mi = cudf.MultiIndex.from_tuples( ... [('a', 'd'), ('b', 'e'), ('b', 'f')]) >>> mi.get_loc('b') slice(1, 3, None) >>> mi.get_loc(('b', 'e')) 1 >>> non_monotonic_non_unique_idx = cudf.MultiIndex.from_tuples( ... [('c', 'd'), ('b', 'e'), ('a', 'f'), ('b', 'e')]) >>> non_monotonic_non_unique_idx.get_loc('b') # differ from pandas slice(1, 4, 2)