BUG: Check for duplicate names columns and index in crosstab
State: closed

- [ ] closes #22529
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


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

Comments:
Sure! Wanted to know that this was the right approach to solving this issue before writing the tests (sorry, first PR to pandas!)
Hello @cuchoi! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:





There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2019-06-09 22:09:06 UTC
Added tests. Basically updated an old test that would break if we used different data. This would break before:

```
""" We create two series, rename one of the columns, 
    do a crosstab and check if they are equal. We expect them to be equal,
    but it fails due to an issue when there are duplicate column names."""
s1 = pd.Series(range(3), name='foo')
s2 = s1 + 1

expected = pd.crosstab(s1, s2.rename("bar"))
result = pd.crosstab(s1, s2)

tm.assert_frame_equal(result, expected)
```

So now I add raises exceptions checking in case that there is:
 - A duplicated index
 - Duplicated columns
 - Name shared between the index and columns.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26717?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@9a67ff4`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `0%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26717/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26717?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #26717   +/-   ##
=========================================
  Coverage          ?   41.19%           
=========================================
  Files             ?      179           
  Lines             ?    50774           
  Branches          ?        0           
=========================================
  Hits              ?    20918           
  Misses            ?    29856           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #single | `41.19% <0%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26717?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/reshape/pivot.py](https://codecov.io/gh/pandas-dev/pandas/pull/26717/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9waXZvdC5weQ==) | `8.02% <0%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26717?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/26717?src=pr&el=footer). Last update [9a67ff4...301eb87](https://codecov.io/gh/pandas-dev/pandas/pull/26717?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/26717?src=pr&el=h1) Report
> Merging [#26717](https://codecov.io/gh/pandas-dev/pandas/pull/26717?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/0f3e8e8bd2118d56c7febe5d6081c5058cb22be7?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26717/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26717?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26717      +/-   ##
==========================================
- Coverage   91.71%    91.7%   -0.01%     
==========================================
  Files         178      178              
  Lines       50740    50747       +7     
==========================================
+ Hits        46538    46540       +2     
- Misses       4202     4207       +5
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <100%> (ø)` | :arrow_up: |
| #single | `41.2% <0%> (-0.12%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26717?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/reshape/pivot.py](https://codecov.io/gh/pandas-dev/pandas/pull/26717/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9waXZvdC5weQ==) | `96.6% <100%> (+0.07%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26717/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26717/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.88% <0%> (-0.12%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26717/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.84% <0%> (-0.11%)` | :arrow_down: |

------

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

can you merge master and see if you can get this passing
@cuchoi pls rebase
Looks like this has gone stale but ping if you'd like to pick it back up
Hi! I rebased. Is it not showing up because the issue is closed? Can your reopen it?
Yes. GitHub struggles with reopening PRs to branches that have been closed. You're probably best off opening a new PR if you're wanting to work on this again!
Thanks! New PR here: https://github.com/pandas-dev/pandas/pull/28474