DOC: Improve the docstring of pd.Index.contains and closes PR #20211
State: closed

- [x] closes #20211 
- [ ] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

This PR is an update to PR #20211, improving the `Index.contains` docstring.




Labels:
name: Docs
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves

Comments:
Hello @Tanya-Jain! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/core/indexes/base.py`](https://github.com/Tanya-Jain/pandas/blob/1d83db4a0965726f94b885a103073dd4ee4f3fc8/pandas/core/indexes/base.py) !


Any reason to close this? I guess it's been by mistake?
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23100?src=pr&el=h1) Report
> Merging [#23100](https://codecov.io/gh/pandas-dev/pandas/pull/23100?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/03134cb92ed61d073438daac7a7c2a0e094efede?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/23100/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23100?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #23100      +/-   ##
==========================================
- Coverage    92.2%    92.2%   -0.01%     
==========================================
  Files         162      162              
  Lines       51701    51700       -1     
==========================================
- Hits        47671    47670       -1     
  Misses       4030     4030
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.6% <100%> (-0.01%)` | :arrow_down: |
| #single | `43.02% <100%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23100?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/23100/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `95.55% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/category.py](https://codecov.io/gh/pandas-dev/pandas/pull/23100/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9jYXRlZ29yeS5weQ==) | `97.9% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23100/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `93.06% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/23100/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `97.29% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/23100/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.27% <100%> (-0.01%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23100?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23100?src=pr&el=footer). Last update [03134cb...93dcd9d](https://codecov.io/gh/pandas-dev/pandas/pull/23100?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

#23100 contained an additional commit for merging commits from the pandas-dev/pandas master. 
To have only the commit for the file changes made in base.py, I closed #23100 and opened #23107
I tried to get the problem fixed but ended up having 0 commits being shown as well as having this PR automatically closed.
- [x] The html page generates correctly with `./doc/make.py html --single=pandas.Index.contains`
- [x] Validation tests passed with a warning of absence of an extended description as asked in the #20211 PR review. Tested via command `./scripts/validate_docstrings.py pandas.Index.contains`
- [x] No doctests problem were reported for lines 2008-2036 by testing via command `flake8 --doctests pandas/core/indexes/base.py`

Validation Script:
```
################################################################################
###################### Docstring (pandas.Index.contains)  ######################
################################################################################

Return a boolean indicating whether this key is in the index.

Parameters
----------
key : label
    The key can be of the same type as the label of :class:`Index`,
    hence immutable-like and 1-dimensional if it is a tuple.

Returns
-------
bool
    Result indicating whether the key search is in the index.

See Also
--------
Index.isin : Returns an ndarray of boolean dtype indicating whether the
    list-like key is in the index.

Examples
--------
>>> idx = pd.Index([1, 2, (3, 4), 5])
>>> idx
Index([1, 2, (3, 4), 5], dtype='object')
>>> idx.contains(1)
True
>>> idx.contains(6)
False
>>> idx.contains((3, 4))
True

################################################################################
################################## Validation ##################################
################################################################################

Warnings found:
	No extended summary found
Docstring for "pandas.Index.contains" correct. :)
```
@jreback if you don't mind reviewing and merging this one too
@Tanya-Jain do you have time to address the comments of the last review and fix the conflicts?
@jreback addressed your comments, and made some other fixes to this docstring, if you can take a look.
thanks @Tanya-Jain and @datapythonista