Allow for dict-like argument to Categorical.rename_categories
State: closed

- [x] closes #17336
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

`Categorical.rename_categories` can now take a dict as `new_categories` and updates the categories to those found in the mapping.
 It will only change the categories found in the dict, and leave all others the same.
The dict can be smaller or larger, and may or may not contain mappings referencing the old categories.

Have a good day/night! 🐼 🐍 

Labels:
name: Enhancement
name: Categorical
description: Categorical Data Type

Comments:
Don't worry about the travis failures. They're unrelated and have been fixed. +1 once you change the `if isinstance(...)` to use `is_dict_like`.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@21a3800`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #17586   +/-   ##
=========================================
  Coverage          ?    91.2%           
=========================================
  Files             ?      163           
  Lines             ?    49627           
  Branches          ?        0           
=========================================
  Hits              ?    45263           
  Misses            ?     4364           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.99% <100%> (?)` | |
| #single | `40.19% <0%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `95.59% <100%> (ø)` | |

------

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

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=h1) Report
> Merging [#17586](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/6930f27e78b2b61a4df31b667a816fa53e49ffed?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #17586      +/-   ##
==========================================
- Coverage   91.19%   91.18%   -0.02%     
==========================================
  Files         163      163              
  Lines       49625    49627       +2     
==========================================
- Hits        45257    45250       -7     
- Misses       4368     4377       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.96% <100%> (ø)` | :arrow_up: |
| #single | `40.19% <0%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `95.59% <100%> (+0.01%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17586?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.77% <0%> (-0.1%)` | :arrow_down: |

------

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

@alanbato : LGTM as well.  Bunch of nit-picking to enhance readability is all I've got above.
Done @gfyoung. Do we wait for green again?
@alanbato : Yes, ping us when it's green.
@TomAugspurger @gfyoung @jreback Ping! 🌵✔️ 
Nice!  I'll let @jreback look this over and merge just to double check.
@jreback 🌵 ✔️ 
thanks @alanbato nice patch!