Skip to content

DOC: Improve the docstring of pd.Index.contains #23107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,15 +2005,37 @@ def __contains__(self, key):
return False

_index_shared_docs['contains'] = """
return a boolean if this key is IN the index
Return a boolean if this key is in the index.

Parameters
----------
key : object
key : label
The key requested. Immutable-like, 1-dimensional.

Returns
-------
boolean
bool
Result of the key search.

See Also
--------
CategoricalIndex : Returns a bool if the 1-dimensional, Categorical key
is in index.
Index.isin : Returns ndarray of boolean dtype if list-like key is in
index.

Examples
--------
>>> l1 = pd.Index([1, 2, (3, 4), 5])
>>> t = (3, 4)
>>> num1 = 1
>>> num2 = 6
>>> l1.contains(num1)
True
>>> l1.contains(num2)
False
>>> l1.contains(t)
True
"""

@Appender(_index_shared_docs['contains'] % _index_doc_kwargs)
Expand Down