From e28ebe3d11c9a923fe9407dafc4cab1005e90d07 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 12 Dec 2019 18:39:52 +0100 Subject: [PATCH] DOC: Add MultiIndex.get_locs to generated reference (#30234) * DOC: Add MultiIndex.get_locs to generated reference * fixups --- doc/source/reference/indexing.rst | 1 + pandas/core/indexes/multi.py | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index ec485675771c4..ab6ea5aea6c61 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -313,6 +313,7 @@ MultiIndex selecting :toctree: api/ MultiIndex.get_loc + MultiIndex.get_locs MultiIndex.get_loc_level MultiIndex.get_indexer MultiIndex.get_level_values diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 57c7cd2df81c1..7b0cc871cbcbc 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -2879,37 +2879,37 @@ def convert_indexer(start, stop, step, indexer=indexer, codes=level_codes): def get_locs(self, seq): """ - Get location for a given label/slice/list/mask or a sequence of such as - an array of integers. + Get location for a sequence of labels. Parameters ---------- - seq : label/slice/list/mask or a sequence of such + seq : label, slice, list, mask or a sequence of such You should use one of the above for each level. If a level should not be used, set it to ``slice(None)``. Returns ------- - locs : array of integers suitable for passing to iloc + numpy.ndarray + NumPy array of integers suitable for passing to iloc. + + See Also + -------- + MultiIndex.get_loc : Get location for a label or a tuple of labels. + MultiIndex.slice_locs : Get slice location given start label(s) and + end label(s). Examples -------- >>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')]) - >>> mi.get_locs('b') + >>> mi.get_locs('b') # doctest: +SKIP array([1, 2], dtype=int64) - >>> mi.get_locs([slice(None), ['e', 'f']]) + >>> mi.get_locs([slice(None), ['e', 'f']]) # doctest: +SKIP array([1, 2], dtype=int64) - >>> mi.get_locs([[True, False, True], slice('e', 'f')]) + >>> mi.get_locs([[True, False, True], slice('e', 'f')]) # doctest: +SKIP array([2], dtype=int64) - - See Also - -------- - MultiIndex.get_loc : Get location for a label or a tuple of labels. - MultiIndex.slice_locs : Get slice location given start label(s) and - end label(s). """ from .numeric import Int64Index