BUG: group with multiple named results
State: closed

- [x] closes #19029 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

This bugfix gets rid of duplicated names that can be the result of groupby operations (#19029).
I opted to implement one of the ideas proposed by [toobaz](https://github.com/pandas-dev/pandas/issues/19029#issuecomment-354684340): duplicated names get suffixed by their corresponding position, i.e. ['name','name'] gets transformed into ['name0', 'name1'].

* A few testcases have been added.
* One particular testcase had to be changed ([test_crosstab_dup_index_names](https://github.com/pandas-dev/pandas/blob/master/pandas/tests/reshape/test_pivot.py))
  - This is because with the new bugfix crosstab does not yield a ValueError anymore.


Labels:
name: Bug
name: Groupby

Comments:
Hello @guenteru! Thanks for updating the PR.









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

##### Comment last updated on May 23, 2018 at 09:46 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21171?src=pr&el=h1) Report
> Merging [#21171](https://codecov.io/gh/pandas-dev/pandas/pull/21171?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/be90d492836fa604b4b914ab6c7387752a6ba9e6?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/21171/graphs/tree.svg?height=150&width=650&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/21171?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #21171      +/-   ##
==========================================
+ Coverage   91.84%   91.84%   +<.01%     
==========================================
  Files         153      153              
  Lines       49505    49510       +5     
==========================================
+ Hits        45466    45471       +5     
  Misses       4039     4039
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21171?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/groupby/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/21171/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGJ5LnB5) | `92.67% <100%> (+0.01%)` | :arrow_up: |
| [pandas/core/indexes/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/21171/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9pbnRlcnZhbC5weQ==) | `93.14% <0%> (ø)` | :arrow_up: |

------

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

closing as stale. if you'd like to continue pls ping.