BUG: Raise ValueError if a column index in usecols is out of bounds. …
State: closed

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


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

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

```diff
@@            Coverage Diff             @@
##           master   #25686      +/-   ##
==========================================
+ Coverage   91.29%   91.29%   +<.01%     
==========================================
  Files         173      173              
  Lines       52961    52970       +9     
==========================================
+ Hits        48350    48359       +9     
  Misses       4611     4611
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.87% <100%> (ø)` | :arrow_up: |
| #single | `41.73% <20%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25686?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/25686/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnNlcnMucHk=) | `95.43% <100%> (+0.08%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25686/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.98% <0%> (-0.1%)` | :arrow_down: |

------

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

```diff
@@            Coverage Diff             @@
##           master   #25686      +/-   ##
==========================================
+ Coverage   91.47%   91.48%   +<.01%     
==========================================
  Files         173      173              
  Lines       52872    52881       +9     
==========================================
+ Hits        48366    48376      +10     
+ Misses       4506     4505       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.04% <100%> (ø)` | :arrow_up: |
| #single | `41.81% <20%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25686?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/25686/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnNlcnMucHk=) | `95.67% <100%> (+0.08%)` | :arrow_up: |

------

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

lgtm. @heckeop can you merge master. ping on green.
can you merge master. ping on green.
Hello @heckeop! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:





There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2019-03-25 02:29:50 UTC
@jreback @WillAyd thoughts?
@jreback Thoughts?
thanks @heckeop the test is pretty clear i think.