Rename categories with Series
State: closed

Closes #17981 

head:

```
[ 50.00%] ··· Running categoricals.Categoricals3.time_rank_string_cat         6.39ms
[100.00%] ··· Running categoricals.Categoricals3.time_rank_string_cat_ordered 4.81ms
```

master:

```
[ 50.00%] ··· Running categoricals.Categoricals3.time_rank_string_cat         137ms
[100.00%] ··· Running categoricals.Categoricals3.time_rank_string_cat_ordered 5.14ms
```

Labels:
name: Performance
description: Memory or execution speed performance
name: Categorical
description: Categorical Data Type

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=h1) Report
> Merging [#17982](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/36c309ed51b98e97fb64238232ecdc795040ad24?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/17982/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #17982      +/-   ##
==========================================
- Coverage   91.23%   91.22%   -0.02%     
==========================================
  Files         163      163              
  Lines       50113    50117       +4     
==========================================
- Hits        45723    45718       -5     
- Misses       4390     4399       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.03% <100%> (ø)` | :arrow_up: |
| #single | `40.3% <0%> (-0.08%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `95.75% <100%> (+0.02%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <0%> (-0.1%)` | :arrow_down: |
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `91.77% <0%> (ø)` | :arrow_up: |
| [pandas/core/reshape/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/17982?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9jb25jYXQucHk=) | `97.58% <0%> (ø)` | :arrow_up: |

------

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

lgtm. merge away.
you *migh* want to add the issue number to the original issue number in the whatsnew (#17336)
It's not really a perf issue, that's just the reason we caught it. The main issue is the API change from


```python
c = pd.Categorical(['a', 'b'])
c.rename(pd.Series([10, 20)
```

Before https://github.com/pandas-dev/pandas/pull/17586, the values would be used, and so the categories would be `[10, 20]`. Afterwards, the series is considered dict-like, so the index -> value mapping is used.

I really don't think we should just break API here. It'll be very surprising and difficult to debug. But in most cases Series is considered dict-like, so I think a warning is the best option here.
why don’t you just make th change to fix this back to how it was; this PR was in 0.21 so it’s not externally visible

warnings are a terrible things and should rarely be used
Just pushed a WIP adding the warning so that we're talking about the same thing, will clean up a bit further.
> why don’t you just make th change to fix this back to how it was;

Not sure what you mean here, revert the entire PR? That's a useful feature, it just (unexpectedly) changes the behavior for Series. We didn't have any tests covering that, so it wasn't caught at the time.
I find the current PR fine: warn for series to say that in future it will use dict-like behaviour, but for now keep list-like behaviour
@jreback are you OK with the `FutureWarning` for now?