BUG: adds validation for boolean keywords in DataFrame.set_index
State: closed

ENH: Adds util._validators.validate_keywords_as_bool decorator

- [x] closes #16714
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

I've used a decorator so that we can check all the boolean kwargs at once rather than have a lot of lines of `validate_bool_kwarg` at the top of every method.

Labels:
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
Oh, and if people are happy with this decorator approach, I can go through and give all methods the same treatment/tests
> Oh, and if people are happy with this decorator approach

Just for reference, can you list 1 - 2 places where this also could be applied?  Seems reasonable otherwise, though I would check performance just in the case the decorator imposes too much overhead.
@gfyoung this could/(should according to @jreback https://github.com/pandas-dev/pandas/issues/16714#issuecomment-309593201) be applied to all boolean keyword arguments.  So I could go through all of DataFrame, Series etc and decorate all methods with boolean kwargs
@richardjgowers : Sure, though if you could specify a couple just for reference which take multiple boolean arguments, that would be great.
@gfyoung just scanning through frame.py I found:

https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L1528
https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L1653
https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L1681
https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L3161
https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L3638
can you rebase; move note to 0.22.0
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@7495e9a`). [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/17853/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #17853   +/-   ##
=========================================
  Coverage          ?   91.21%           
=========================================
  Files             ?      163           
  Lines             ?    50048           
  Branches          ?        0           
=========================================
  Hits              ?    45650           
  Misses            ?     4398           
  Partials          ?        0
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/\_validators.py](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX3ZhbGlkYXRvcnMucHk=) | `94.82% <100%> (ø)` | |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17853?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/17853?src=pr&el=footer). Last update [7495e9a...9d22f46](https://codecov.io/gh/pandas-dev/pandas/pull/17853?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/17853?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@7495e9a`). [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/17853/graphs/tree.svg?src=pr&token=eZ4WkYLtcO&width=650&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #17853   +/-   ##
=========================================
  Coverage          ?   91.21%           
=========================================
  Files             ?      163           
  Lines             ?    50048           
  Branches          ?        0           
=========================================
  Hits              ?    45650           
  Misses            ?     4398           
  Partials          ?        0
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <100%> (ø)` | |
| [pandas/util/\_validators.py](https://codecov.io/gh/pandas-dev/pandas/pull/17853?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX3ZhbGlkYXRvcnMucHk=) | `94.82% <100%> (ø)` | |

------

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

closing as stale, if you want to work on this, pls ping.