-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update the pd.Index.contains docstring #20211
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't be anything: |
||
Key to be searched. | ||
|
||
Returns | ||
------- | ||
boolean | ||
bool | ||
Result of the key search. | ||
|
||
Notes | ||
----- | ||
CategoricalIndex is a sub-class of Index. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think you need this Notes section. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a See Also with Index.isin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this note is because of shared documentation between Index and CategoricalIndex |
||
|
||
Examples | ||
-------- | ||
>>> pd.CategoricalIndex([2000, 2001, 2012]).contains(2001) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best to just use a regular Index here, not a CategoricalIndex. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pd.Index.contains and pd.CategoricalIndex.contains have shared documentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah for this particular case I would separate the doc-strings, IOW 1 more Index and a separate one for CategoricalIndex. Can use a shared doc if that works (with templates) |
||
True | ||
>>> pd.CategoricalIndex([2000, 2001, 2012]).contains(2222) | ||
False | ||
""" | ||
|
||
@Appender(_index_shared_docs['contains'] % _index_doc_kwargs) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this extended summary can be removed.