fix for TypeError: unorderable types" in when using set_index with multiple column names
State: closed

- closes #15457

Labels:
name: Bug
name: MultiIndex
name: IO LaTeX
description: to_latex

Comments:
Going to need tests for this as well.
> closes #16718

Thanks for your attempt! But is this really the bug you're after?! (feel free to edit the description)
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22072?src=pr&el=h1) Report
> Merging [#22072](https://codecov.io/gh/pandas-dev/pandas/pull/22072?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/0370740034978d3a63d4b8e5e2c96ff54e7e08ba?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

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

```diff
@@           Coverage Diff           @@
##           master   #22072   +/-   ##
=======================================
  Coverage   92.08%   92.08%           
=======================================
  Files         169      169           
  Lines       50694    50694           
=======================================
  Hits        46682    46682           
  Misses       4012     4012
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.49% <100%> (ø)` | :arrow_up: |
| #single | `42.34% <100%> (ø)` | :arrow_up: |

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

------

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

Hello @dickreuter! Thanks for updating the PR.





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

##### Comment last updated on August 11, 2018 at 12:07 Hours UTC
* Changed the description to point to the correct bug: #15457
* Added test
* Better doc
Would like to check it locally but building pandas seems impossible (cl.exe failed with exit status 2). Is there no additional info what version of visual studio dev tools is needed exactly? https://stackoverflow.com/questions/51566895/unable-to-build-pandas-from-source-cl-exe-failed-with-exit-status-2
http://pandas-docs.github.io/pandas-docs-travis/contributing.html#installing-a-c-compiler And 
https://devguide.python.org/setup/#build-dependencies may help
I don't see how the error on the ci is related to my change (especially also since the tests passed yesterday)
> I don't see how the error on the ci is related to my change (especially also since the tests passed yesterday)

At least one is explained by
```
pandas/tests/arrays/categorical/test_indexing.py:131:41: W292 no newline at end of file
```
(see also the automatic [comment](https://github.com/pandas-dev/pandas/pull/22072#issuecomment-408561159)  by @pep8speaks )
Still getting an error which I can't see how it's related to this: BufferError: could not get scalar buffer information. Running this test locally passes fine.
@toobaz: I'm getting `ValueError: setting an array element with a sequence` when I test that. Not sure my fix is related to this bug?
@toobaz I reverted to the test via dict as otherwise line 908 of cast.py causes an error when trying to create an array from  [1, (1, 2)], raising {ValueError}setting an array element with a sequence.
@toobaz @jreback What's the next step? Can this be merged? tx
https://travis-ci.org/pandas-dev/pandas/jobs/413344917#L3557

@dickreuter : You have linter failures.  I would fix those first before pinging.
> let's just compare the DataFrame itself (after all that's the OP)

@jreback My suggestion was based on the fact that the OP's error comes from an internal public API call. By testing this call directly (the index creation), we are not looking at the bug from another point of view: it is a test to exactly the same problematic code path, just better classified..
rebased

@toobaz merge when satisfied
@toobaz Why does travis fail with "Unable to download 3.5 archive. The archive may not exist. Please consider a different version"?
Thanks @dickreuter !
@dickreuter : FYI, those Travis failures that you saw [earlier](https://github.com/pandas-dev/pandas/pull/22072#issuecomment-412297820) are spurious.  I restarted the builds to get them passing and this PR merged 🙂