Add 'name' as argument for index 'to_frame' method
State: closed

- [ ] closes #xxxx
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Since series `to_frame` method has a `name` argument, I believe it makes sense for index also have it.

Labels:
name: Enhancement
name: Compat
description: pandas objects compatability with Numpy or Python functions
name: Needs Discussion
description: Requires discussion from core team before further action

Comments:
The problem is that a name argument doesn’t make sense for a MultiIndex. Not sure what’s best here. 
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22580?src=pr&el=h1) Report
> Merging [#22580](https://codecov.io/gh/pandas-dev/pandas/pull/22580?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/b23a0e8fc36f14afc7d180f68f082dcfe88ddc23?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/22580/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/22580?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #22580      +/-   ##
==========================================
+ Coverage   92.17%   92.17%   +<.01%     
==========================================
  Files         169      169              
  Lines       50708    50716       +8     
==========================================
+ Hits        46740    46748       +8     
  Misses       3968     3968
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.58% <100%> (ø)` | :arrow_up: |
| #single | `42.34% <18.18%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22580?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/22580/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `95.43% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/22580/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.45% <100%> (ø)` | :arrow_up: |

------

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

@TomAugspurger regarding MultiIndex, I'm not seeing how this `name` will affect MultiIndex. Can you enlight me please?
Override for MI with plural names?
Probably best to keep the signature the same for MI, but indicate that
`name` should be a sequence of strings matching the number of levels.

Can you add a test for that, and implement it if it's broken?

On Mon, Sep 3, 2018 at 12:20 PM jbrockmendel <notifications@github.com>
wrote:

> Override for MI with plural names?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/22580#issuecomment-418165021>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIsYSWknpOduW3KyEA1uzSpohgEfQks5uXWTxgaJpZM4WXb1h>
> .
>

@henriqueribeiro : Thanks for the contribution!  In the future, if you could open an issue *before* opening the PR, that would allow us to evaluate the idea first before implementing.
Hello @henriqueribeiro! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/indexes/base.py`](https://github.com/henriqueribeiro/pandas/blob/b0eaa7cc18d53c93eb0dfab156ad77262af1235f/pandas/core/indexes/base.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/multi.py`](https://github.com/henriqueribeiro/pandas/blob/b0eaa7cc18d53c93eb0dfab156ad77262af1235f/pandas/core/indexes/multi.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/common.py`](https://github.com/henriqueribeiro/pandas/blob/b0eaa7cc18d53c93eb0dfab156ad77262af1235f/pandas/tests/indexes/common.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/multi/test_conversion.py`](https://github.com/henriqueribeiro/pandas/blob/b0eaa7cc18d53c93eb0dfab156ad77262af1235f/pandas/tests/indexes/multi/test_conversion.py) !



##### Comment last updated on September 08, 2018 at 15:33 Hours UTC
@gfyoung Sure! Sorry for that
@TomAugspurger I cannot understand why some checks are failing. Can you give me some help please?
There was  a new release of openpyxl that's incompatible with pandas. It's been worked around on master, so you need to fetch upstream and push your changes.

```
git fetch upstream
git merge upstream/master
git push origin
```
@henriqueribeiro linting error https://travis-ci.org/pandas-dev/pandas/jobs/425773293#L3653 and it looks like you may need to merge master still.
Needs a release note too, for 0.24
@TomAugspurger Regarding the release notes, should I add this on the indexing section of v0.24.0.txt?
Probably under the "Other Enhancements" section.

On Tue, Sep 11, 2018 at 5:23 AM henriqueribeiro <notifications@github.com>
wrote:

> @TomAugspurger <https://github.com/TomAugspurger> Regarding the release
> notes, should I add this on the indexing section of v0.24.0.txt?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/22580#issuecomment-420224335>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIrIxCtuDKYcHf8Zju-pGGLo8Rin7ks5uZ48PgaJpZM4WXb1h>
> .
>

lgtm. was there not a referenced issue?
No. This came from dask and that's why I created the pull request immediately. 
All green, and since @jreback has already approved this, merging.
Thanks @henriqueribeiro !
Thanks to @TomAugspurger for this "ping-pong" fixing.