BUG: Check types in Index.__contains__ (#22085)
State: closed

- [x] closes #22085
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

I added is_float, is_integer_dtype in Index.__contains__.
If key is float and dtype of Index object is integer, return False.

And this is the same as #22360. I deleted the branch while rebasing it... 😅

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

Comments:
Hello @yeojin-dev! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/indexes/numeric.py`](https://github.com/yeojin-dev/pandas/blob/39fab6a24c428a9e47fe0ea796b3c6df108c017b/pandas/core/indexes/numeric.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexing/test_indexing.py`](https://github.com/yeojin-dev/pandas/blob/39fab6a24c428a9e47fe0ea796b3c6df108c017b/pandas/tests/indexing/test_indexing.py) !



##### Comment last updated on September 19, 2018 at 12:28 Hours UTC
If you fetch and merge master the CI failures should be fixed.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22602?src=pr&el=h1) Report
> Merging [#22602](https://codecov.io/gh/pandas-dev/pandas/pull/22602?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/1a12c41d201f56439510e683fadfed1218ea9067?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #22602      +/-   ##
==========================================
+ Coverage   92.16%   92.16%   +<.01%     
==========================================
  Files         169      169              
  Lines       50769    50778       +9     
==========================================
+ Hits        46791    46800       +9     
  Misses       3978     3978
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.58% <100%> (ø)` | :arrow_up: |
| #single | `42.33% <90.9%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22602?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/22602/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9udW1lcmljLnB5) | `97.41% <100%> (+0.1%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22602?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/22602?src=pr&el=footer). Last update [1a12c41...39fab6a](https://codecov.io/gh/pandas-dev/pandas/pull/22602?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jreback Please check. 😆
thanks @yeojin-dev sorry for the back and forth, sometimes hard to figure out where to put things
@jreback Thanks. 😆