Fix categorical from codes nan 21767
- [x] closes #21767
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

lgtm. ping on green. I would slightly prefer to warn for a version when people provide floats. The current changes breaks `Categorical.from_codes([1.0, 0.0], ['a', 'b'])`, which is incorrect, but previously worked.

We can consider checking whether `np.all(codes == codes.astype(int))`, to detect cases like `np.nan`. # [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21775?src=pr&el=h1) Report
> Merging [#21775](https://codecov.io/gh/pandas-dev/pandas/pull/21775?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/26b3e7de56fdebaf1842b01d747a1a30a126c54a?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/21775/graphs/tree.svg?token=eZ4WkYLtcO&width=650&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/21775?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #21775      +/-   ##
==========================================
- Coverage   92.07%   92.06%   -0.01%     
==========================================
  Files         170      170              
  Lines       50688    50700      +12     
==========================================
+ Hits        46671    46678       +7     
- Misses       4017     4022       +5
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.47% <100%> (-0.01%)` | :arrow_down: |
| #single | `42.28% <25%> (-0.03%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21775?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/21775/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.75% <100%> (-0.21%)` | :arrow_down: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/21775/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `94.87% <0%> (-0.34%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/21775/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `85.69% <0%> (-0.21%)` | :arrow_down: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/21775/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `95.44% <0%> (-0.03%)` | :arrow_down: |
| [pandas/core/dtypes/dtypes.py](https://codecov.io/gh/pandas-dev/pandas/pull/21775/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2R0eXBlcy5weQ==) | `96.05% <0%> (+0.02%)` | :arrow_up: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/21775/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `93.5% <0%> (+0.1%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21775?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/21775?src=pr&el=footer). Last update [26b3e7d...b8d4b83](https://codecov.io/gh/pandas-dev/pandas/pull/21775?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 Hello @miker985! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on July 31, 2018 at 14:49 Hours UTC @miker985 can you merge in master and fix the conflict? @jreback It says you have requested changes but I think I have addressed them. Can you comment? @jreback pinging again - I'm not clear if I've fixed the requested changes and the tool is broken, or if I've missed something (it shows changes requested, but then says the area you requested them is outdated) @jreback ping thanks @miker985 nice patch! 