Skip to content

Commit b8c705b

Browse files
committed
DOC: Improve the docstring of pd.Index.contains and PR20211
1 parent ce1f81f commit b8c705b

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

pandas/core/indexes/base.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,15 +2005,37 @@ def __contains__(self, key):
20052005
return False
20062006

20072007
_index_shared_docs['contains'] = """
2008-
return a boolean if this key is IN the index
2008+
Return a boolean if this key is in the index.
20092009
20102010
Parameters
20112011
----------
2012-
key : object
2012+
key : label
2013+
The key requested. Immutable-like, 1-dimensional.
20132014
20142015
Returns
20152016
-------
2016-
boolean
2017+
bool
2018+
Result of the key search.
2019+
2020+
See Also
2021+
--------
2022+
CategoricalIndex : Returns a bool if the 1-dimensional, Categorical key
2023+
is in index.
2024+
Index.isin : Returns ndarray of boolean dtype if list-like key is in
2025+
index.
2026+
2027+
Examples
2028+
--------
2029+
>>> l1 = pd.Index([1, 2, (3, 4), 5])
2030+
>>> t = (3, 4)
2031+
>>> num1 = 1
2032+
>>> num2 = 6
2033+
>>> l1.contains(num1)
2034+
True
2035+
>>> l1.contains(num2)
2036+
False
2037+
>>> l1.contains(t)
2038+
True
20172039
"""
20182040

20192041
@Appender(_index_shared_docs['contains'] % _index_doc_kwargs)

0 commit comments

Comments
 (0)