diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 6a56278b0da49..ffe8ea51a64a2 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3146,17 +3146,22 @@ def droplevel(self, level=0): .. versionadded:: 0.21.0 (list-like tolerance) - Examples - -------- - >>> indexer = index.get_indexer(new_index) - >>> new_values = cur_values.take(indexer) - Returns ------- indexer : ndarray of int Integers from 0 to n - 1 indicating that the index at these positions matches the corresponding target values. Missing values in the target are marked by -1. + + Examples + -------- + >>> index = pd.Index(['c', 'a', 'b']) + >>> index.get_indexer(['a', 'b', 'x']) + array([ 1, 2, -1]) + + Notice that the return value is an array of locations in ``index`` + and ``x`` is marked by -1, as it is not in ``index``. + """ @Appender(_index_shared_docs['get_indexer'] % _index_doc_kwargs)