From 71aa7ef8a3c17d637357fd88020fae78a85483a2 Mon Sep 17 00:00:00 2001 From: Attila Nemet Date: Sat, 10 Mar 2018 19:13:56 +0100 Subject: [PATCH] DOC: Improve the docstring of pd.Index.contains --- pandas/core/indexes/base.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 888507a529687..85fbde799dae7 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1832,15 +1832,31 @@ def __contains__(self, key): return False _index_shared_docs['contains'] = """ - return a boolean if this key is IN the index + Return a boolean if key is in the index. + + This function returns True if key is in the index and + returns False if key is not in index. Parameters ---------- - key : object + key : immutable object + Key to be searched. Returns ------- - boolean + bool + Result of the key search. + + Notes + ----- + CategoricalIndex is a sub-class of Index. + + Examples + -------- + >>> pd.CategoricalIndex([2000, 2001, 2012]).contains(2001) + True + >>> pd.CategoricalIndex([2000, 2001, 2012]).contains(2222) + False """ @Appender(_index_shared_docs['contains'] % _index_doc_kwargs)