ENH: level keyword in rename (GH4160)
State: closed

- [ ] part of #4160
- [ ] tests added / passed
- [ ] passes `git diff upstream/master | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Enhancement
name: MultiIndex

Comments:
this looks pretty good. maybe rebase and see where we are.

@jorisvandenbossche ?
Trying to revive this. @jreback I am not sure anymore what was missing before, but can you clarify your comment a bit?
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=h1) Report
> Merging [#13766](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/1751628adef96b913d0083a48e51658a70dac8c4?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/13766/graphs/tree.svg?src=pr&width=650&token=eZ4WkYLtcO&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #13766      +/-   ##
==========================================
+ Coverage      91%      91%   +<.01%     
==========================================
  Files         145      145              
  Lines       49581    49586       +5     
==========================================
+ Hits        45122    45128       +6     
+ Misses       4459     4458       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.77% <100%> (ø)` | :arrow_up: |
| #single | `40.57% <60%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `93.55% <100%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.26% <100%> (ø)` | :arrow_up: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `90.68% <0%> (-0.35%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `81.13% <0%> (+0.18%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/13766?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/13766?src=pr&el=footer). Last update [1751628...0065973](https://codecov.io/gh/pandas-dev/pandas/pull/13766?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/13766?src=pr&el=h1) Report
> Merging [#13766](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cd1031f28664928c7e258dbb04d1f5861bad6b37?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/13766/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #13766      +/-   ##
==========================================
+ Coverage   90.99%   90.99%   +<.01%     
==========================================
  Files         153      153              
  Lines       50481    50486       +5     
==========================================
+ Hits        45937    45942       +5     
  Misses       4544     4544
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.76% <100%> (ø)` | :arrow_up: |
| #single | `40.43% <60%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `93.55% <100%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/13766?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.29% <100%> (ø)` | :arrow_up: |

------

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

@jreback I merged this, as I currently don't have time to address the clean-up comment (and I just used what was already in place). Do you find it worth to open an issue to keep track of that comment?
create a new issue to track this and mark it for 0.20.0 I will get to this. This impl is not consistent with how things are done internally.
https://github.com/pandas-dev/pandas/issues/16045