BUG: Let MultiIndex.set_levels accept any iterable (#23273)
State: closed

- [x] closes #23273
- [x] tests added and passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Quite surprisingly, `is_list_like` accepts a wide range of iterables including non-subscriptable objects. Later in the code `set_levels` implicitly supposes that passed instance can return its 0'th element by index, which is not always the case, as provided in the example of the #23273.

To address the issue, a new helper function `is_subscriptable` is added, and if passed levels look like a list, but are not subscriptable, they are explicltly converted to a list with `list(levels)`


Labels:
name: Bug
name: MultiIndex

Comments:
Hello @imankulov! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/core/dtypes/inference.py`](https://github.com/imankulov/pandas/blob/d0257cb6258f5347ab2f5ea124d065ecbba47924/pandas/core/dtypes/inference.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/multi.py`](https://github.com/imankulov/pandas/blob/d0257cb6258f5347ab2f5ea124d065ecbba47924/pandas/core/indexes/multi.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/multi/test_get_set.py`](https://github.com/imankulov/pandas/blob/d0257cb6258f5347ab2f5ea124d065ecbba47924/pandas/tests/indexes/multi/test_get_set.py) !


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23291?src=pr&el=h1) Report
> Merging [#23291](https://codecov.io/gh/pandas-dev/pandas/pull/23291?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/1c26375c0743a2cbdcfe14a62ad10806001cbee8?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/23291/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23291?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #23291      +/-   ##
==========================================
+ Coverage   92.22%   92.22%   +<.01%     
==========================================
  Files         169      169              
  Lines       50911    50913       +2     
==========================================
+ Hits        46954    46956       +2     
  Misses       3957     3957
```

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

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

------

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

Thanks for the review @jreback. Addressed all comments. Need advice on how to deal better with set_index(CategoricalIndex)
thanks!