BUG: usecols kwarg accepts string when it should only allow list-like or callable.
State: closed

- [x] closes #20529 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Since string is iterable, when passed into usecols in read_csv or read_table, it is currently treated as array of characters instead of being caught properly. For example, when usecols='bar', it is interpreted as ['b', 'a' ,'r'] in TextReader, and raising a column not found error in _validate_usecols_names when it really should raise ValueError as invalid value from _validate_usecols_arg, before the param being passed into TextReader.

It's a bug in _validate_usecols_arg and TextReader which lack handling of string-type iterable.

```
>>> import os
>>> from itertools import repeat
>>> from pandas import *
>>>
>>> dummy = DataFrame({"foo": range(0, 5),
...                    "bar": range(10, 15),
...                    "b": [1, 2, 3, 5, 5],
...                    "a": list(repeat(3, 5)),
...                    "r": list(repeat(8, 5))})
>>>
>>> dummy.to_csv('dummy.csv', index=False)
>>> read_csv('dummy.csv', usecols=['foo'])
   foo
0    0
1    1
2    2
3    3
4    4
>>> read_csv('dummy.csv', usecols='bar')
   b  a  r
0  1  3  8
1  2  3  8
2  3  3  8
3  5  3  8
4  5  3  8
>>>
>>> os.remove('dummy.csv')
```


Added is_list_like check in _validate_usecols_arg to ensure passed value is list-like but not string. Also, array_like is defined as list_like with dtype attribute so update docstring to list-like from array-like.

Labels:
name: Error Reporting
description: Incorrect or improved errors from pandas
name: IO CSV
description: read_csv, to_csv

Comments:
can you add a whatsnew note.

@gfyoung can you review
This patch looks pretty good!  Save a few comments and the `whatsnew`, this should be merge-able.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20558?src=pr&el=h1) Report
> Merging [#20558](https://codecov.io/gh/pandas-dev/pandas/pull/20558?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/0a003651a67854b9776c46469a18e20ffd61f141?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #20558      +/-   ##
==========================================
- Coverage   91.83%   91.82%   -0.02%     
==========================================
  Files         152      152              
  Lines       49260    49273      +13     
==========================================
+ Hits        45240    45243       +3     
- Misses       4020     4030      +10
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.2% <100%> (-0.02%)` | :arrow_down: |
| #single | `41.9% <42.85%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20558?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnNlcnMucHk=) | `95.46% <100%> (ø)` | :arrow_up: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.07% <0%> (-1.74%)` | :arrow_down: |
| [pandas/io/clipboard/clipboards.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NsaXBib2FyZC9jbGlwYm9hcmRzLnB5) | `30.58% <0%> (-1.6%)` | :arrow_down: |
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `95.53% <0%> (ø)` | :arrow_up: |
| [pandas/io/formats/terminal.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvdGVybWluYWwucHk=) | `20.98% <0%> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.19% <0%> (ø)` | :arrow_up: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `93.88% <0%> (+0.02%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `84.73% <0%> (+0.2%)` | :arrow_up: |
| [pandas/compat/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/20558/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9fX2luaXRfXy5weQ==) | `58.43% <0%> (+0.69%)` | :arrow_up: |

------

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

@jreback added test.
thanks @minggli keep em coming!
happy to contribute. thanks for reviewing @jreback and @gfyoung !