BUG: GH17464 MultiIndex now raises an error when levels aren't unique, tests changed
State: closed

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


Labels:
name: Bug
name: MultiIndex

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17971?src=pr&el=h1) Report
> Merging [#17971](https://codecov.io/gh/pandas-dev/pandas/pull/17971?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/e1dabf37645f0fcabeed1d845a0ada7b32415606?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `50%`.

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

```diff
@@            Coverage Diff             @@
##           master   #17971      +/-   ##
==========================================
- Coverage   91.23%   91.22%   -0.02%     
==========================================
  Files         163      163              
  Lines       50113    50115       +2     
==========================================
- Hits        45723    45715       -8     
- Misses       4390     4400      +10
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.03% <50%> (-0.01%)` | :arrow_down: |
| #single | `40.31% <50%> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17971?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `96.32% <50%> (-0.08%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <0%> (-0.1%)` | :arrow_down: |

------

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

```diff
@@            Coverage Diff             @@
##           master   #17971      +/-   ##
==========================================
+ Coverage   91.44%   91.45%   +<.01%     
==========================================
  Files         157      157              
  Lines       51378    51441      +63     
==========================================
+ Hits        46985    47044      +59     
- Misses       4393     4397       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.32% <100%> (+0.02%)` | :arrow_up: |
| #single | `40.6% <50%> (-0.08%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17971?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `96.28% <100%> (-0.16%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/indexes/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9pbnRlcnZhbC5weQ==) | `93.05% <0%> (-0.17%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.81% <0%> (-0.1%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.45% <0%> (-0.03%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.69% <0%> (-0.03%)` | :arrow_down: |
| [pandas/core/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS5weQ==) | `92.04% <0%> (ø)` | :arrow_up: |
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `94.47% <0%> (ø)` | :arrow_up: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `94.8% <0%> (+0.04%)` | :arrow_up: |
| ... and [5 more](https://codecov.io/gh/pandas-dev/pandas/pull/17971/diff?src=pr&el=tree-more) | |

------

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

Sure thing
looks like you need to rebase against master, seems you have pulled in other commits

```
git pull --rebase origin/master -i
```

then force push
My mistake, latest push should clear that up
I rebased you. I still need to look at this for review.
can you run the asv for multi and see if any perf changes with this? (prob no, but just checking)
asv shows nasty perf changes though I think it may be a problem with my setup. I'll see if I can work it out. Here's the output for good measure.
```
       before           after         ratio
     [4af9a8b6]       [cdea7fec]
+     16.9±0.03ms      40.2±0.02ms     2.38  categoricals.Categoricals.time_constructor_all_nan
+      23.7±0.2ms         27.4±2ms     1.16  frame_methods.Dropna.time_dropna_axis0_all
+     9.42±0.05μs       10.9±0.2μs     1.15  indexing.Int64Indexing.time_iloc_scalar
+      38.3±0.1ms       43.5±0.8ms     1.14  stat_ops.stats_rolling_mean.time_rolling_median
+         724±5ns          821±8ns     1.13  period.Properties.time_year
+      43.0±0.2ms       48.8±0.2ms     1.13  timedelta.ToTimedelta.time_convert_coerce
+       427±0.4μs          474±3μs     1.11  groupby.GroupBySuite.time_std('int', 100)
+        1.61±0ms      1.77±0.02ms     1.10  strings.StringMethods.time_contains_many_noregex
-         856±8ns          747±4ns     0.87  period.Properties.time_is_leap_year
-        45.9±1ms       38.3±0.2ms     0.83  gil.nogil_take1d_int64.time_nogil_take1d_int64

SOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.
```
can you rebase 
Rebased
Looks like some tests from test_groupby were duplicated in test_functional, without the modifications. I updated the duplicated function in test_functional to get rid of the error - let me know if you think it would be better to remove all the duped tests instead.
@jreback Okay, addressed those issues
thanks @cmazzullo 
No problem