Adding Multiindex support to dataframe pivot function(Fixes #21425)
State: closed

- [x] closes #21425
- [x] tests added/passed:
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew : Now dataframe.pivot function can take multiple columns as index 
        Added extra case to handle indexing on multiple colums in dataframe.pivot function


Labels:
name: Bug
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode

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

```diff
@@            Coverage Diff             @@
##           master   #21467      +/-   ##
==========================================
+ Coverage    91.9%    91.9%   +<.01%     
==========================================
  Files         154      154              
  Lines       49657    49667      +10     
==========================================
+ Hits        45638    45648      +10     
  Misses       4019     4019
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.28% <100%> (ø)` | :arrow_up: |
| #single | `41.89% <0%> (-0.01%)` | :arrow_down: |

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

------

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

@NikhilKumarM : Off to a good start here!  Going to need a `whatsnew` entry + test (can use the example that @jorisvandenbossche gave).
Thanks @gfyoung . I have added test cases and **whatsnew** entry
@NikhilKumarM : You actually need to add the `whatsnew` entry (search for the `v0.23.2.txt` file and test cases to your PR changes 😄 .
@NikhilKumarM Did you push your new changes? Because they do not show up on github here. Normally you only need to add new commits to the same branch, push that to github, and the PR here should get updated.
@jorisvandenbossche : If you look at the PR description, you can see that @NikhilKumarM accidentally added them there.  If this PR goes unresponsive, I can bring it to the finish line.
Hello @NikhilKumarM! Thanks for updating the PR.





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

##### Comment last updated on July 01, 2018 at 13:52 Hours UTC
- Sure. I will try to add ability to pass multiple values for columns.
- I have not worked on docstrings before. Is there any good resource to start doing that? @jorisvandenbossche 
@NikhilKumarM there is a section in the contributing guide focused on docstrings:

https://pandas.pydata.org/pandas-docs/stable/contributing_docstring.html
Why is continuous-integration/travis-ci failing?
> Why is continuous-integration/travis-ci failing?

@NikhilKumarM : Restarted Travis for you.  Failure unrelated to PR.
@jreback @gfyoung @jorisvandenbossche  
Could you please check my last commit and suggest changes. I have modified the code to handle when there is no 'values' argument for 'pivot' function and also added a test case for that. But I do not know if have done it in an optimal way.
@NikhilKumarM : Got a linting error on Travis:

https://travis-ci.org/pandas-dev/pandas/jobs/398632775#L2904
@gfyoung  Fixed the linting error.
@gfyoung @jreback  Could you please give me your feedback on my last commit? 

also needs to rebase
can you merge master
Sure!
can you update
can you merge master
I think pivot function has been removed from reshape.py and put in pivot.py. I will rebase with the master and make necessary changes by this weekend. Thank you !!
can you merge master and update
Closing as stale - ping if you'd like to reopen and continue working this