CLN: Comparison methods for MultiIndex should have consistent behaviour for all nlevels  (GH21149)
State: closed

- [x] closes #21149 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Initial PR #21182 is closed - and now split in 2 different PRs

`def cmp_method` raised ValueError for equality / inequality comparisons of MultiIndex with nlevels == 1, which was inconsistent with behaviour for MultiIndex with nlevels > 1 (details of issue below) - this has now been fixed

Currently (as of 0.23.0), comparing MultiIndex of nlevels==1 with another of same length raises a ValueError e.g.
```python
[In] midx=pd.MultiIndex.from_product([[0, 1]])
[In] midx
[Out] MultiIndex(levels=[[0, 1]],
           labels=[[0, 1]])
[In] midx == midx
[Out] ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```
whereas the behaviour should be consistent with that for MultiIndex with nlevels>1 as follows:
```python
[In] midx == midx
[Out] array([ True,  True])
```

Labels:
name: MultiIndex
name: Clean

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





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

##### Comment last updated on June 14, 2018 at 10:23 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21195?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@fd121ed`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #21195   +/-   ##
=========================================
  Coverage          ?    91.9%           
=========================================
  Files             ?      153           
  Lines             ?    49607           
  Branches          ?        0           
=========================================
  Hits              ?    45590           
  Misses            ?     4017           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <100%> (?)` | |
| #single | `41.89% <100%> (?)` | |

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

------

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

> def cmp_method raised ValueError for equality / inequality comparisons of MultiIndex with nlevels == 1

Good catch!
@jreback @toobaz are any other edits needed on this? Thanks
Any other work needed on this PR? Thanks
thanks, if anything residual is remaining from #21149 let's open a new issue