Use a more helpful error message for invalid correlation methods in DataFrame.corr
State: closed

`DataFrame.corr` currently returns a `KeyError` for invalid correlation methods.  The proposed change would instead return a `ValueError` with an error message reminding the user of the valid correlation methods.

```
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.normal(size=(10, 3)))
df.corr(method="turkey")
```

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

Comments:
Hello @dsaxton! Thanks for updating the PR.









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

##### Comment last updated on August 14, 2018 at 15:49 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22298?src=pr&el=h1) Report
> Merging [#22298](https://codecov.io/gh/pandas-dev/pandas/pull/22298?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/601d71fcfa9081fa88e5c20148972cd766396cd7?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #22298      +/-   ##
==========================================
- Coverage   92.08%   92.05%   -0.03%     
==========================================
  Files         169      169              
  Lines       50706    50713       +7     
==========================================
- Hits        46691    46683       -8     
- Misses       4015     4030      +15
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.46% <100%> (-0.03%)` | :arrow_down: |
| #single | `42.25% <0%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22298?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.25% <100%> (+0.01%)` | :arrow_up: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `93.73% <100%> (+0.01%)` | :arrow_up: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `93.83% <0%> (-0.81%)` | :arrow_down: |
| [pandas/core/dtypes/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL21pc3NpbmcucHk=) | `92.98% <0%> (-0.59%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `85.85% <0%> (-0.21%)` | :arrow_down: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.44% <0%> (-0.05%)` | :arrow_down: |
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `83.48% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `95.41% <0%> (+0.07%)` | :arrow_up: |
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/22298/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `96.71% <0%> (+0.14%)` | :arrow_up: |

------

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

Thanks. Could you add a release note in 0.24.0, and a test to ensure that code is hit for bad inputs?
I'm working on some additional modifications to the DataFrame correlation methods to address some potential bugs I found and close another existing issue, is it okay if I close this pull request and reopen another with all the changes?
no pls don’t

put independent changes in independent PRs
@jreback Looks like the tests passed.  Let me know if there are any other changes that should be made, if not, thanks for all your help.
Thanks @dsaxton!
@TomAugspurger Happy to help!