From 3dbbf97f34509ce856bc6eac5c4c62ce514e43ac Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 12 Dec 2019 16:57:02 +0100 Subject: [PATCH 1/2] DOC: Add MultiIndex.get_locs to generated reference --- doc/source/reference/indexing.rst | 1 + 1 file changed, 1 insertion(+) 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 From 418dedf6ae966f65233a982efaf3cbbc7c258224 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 12 Dec 2019 10:30:43 -0600 Subject: [PATCH 2/2] fixups --- pandas/core/indexes/multi.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) 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