BUG: Fix exceptions when Series.interpolate's `order` parameter is missing or invalid
State: closed

closes #24014
xref #10633
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Before this change, when the `Series.interpolate()` method was called with invalid arguments,  exceptions with informative messages would be raised internally, but then caught and suppressed.  An exception with a potentially misleading message would be raised instead.

For example, when interpolate is called with `method='spline'`, an `order` argument must also be supplied.  This is checked internally, but when the `order` argument was missing, a confusing error would be raised:
```
>>> import pandas as pd
>>> s = pd.Series([0, 1, pd.np.nan, 3, 4])
>>> s.interpolate(method='spline')
Traceback (most recent call last):
...
ValueError: invalid method 'spline' to interpolate.
```

This problem was reported as issues #10633 and #24014.

After this change, a specific and correct exception (previously caught and discarded internally) is raised:
```
>>> import pandas as pd
>>> s = pd.Series([0, 1, pd.np.nan, 3, 4])
>>> s.interpolate(method='spline')
...
ValueError: You must specify the order of the spline or polynomial.
```

In addition, light validation is now performed on the `order` parameter before it is passed to a `scipy` class.  Previously, `pandas` would check if `order` was truthy in the Python sense.  If `order` was non-zero and invalid, a scipy error would propagate to the user:
```
>>> s.interpolate(method='spline', order=-1)
Traceback (most recent call last):
...
dfitpack.error: (1<=k && k<=5) failed for 3rd argument k: fpcurf0:k=-1
```

After this change, a more understandable exception is raised in this case:
```
>>> s.interpolate(method='spline', order=-1)
Traceback (most recent call last):
...
ValueError: order needs to be specified and greater than 0
```

Labels:
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25246?src=pr&el=h1) Report
> Merging [#25246](https://codecov.io/gh/pandas-dev/pandas/pull/25246?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2448e5229683acbe7de57f2d53065247aa085b1f?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #25246      +/-   ##
==========================================
- Coverage    91.9%    91.9%   -0.01%     
==========================================
  Files         166      166              
  Lines       52213    52210       -3     
==========================================
- Hits        47985    47981       -4     
- Misses       4228     4229       +1
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25246?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/25246/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.02% <100%> (-0.09%)` | :arrow_down: |
| [pandas/core/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25246/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbWlzc2luZy5weQ==) | `92.56% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25246?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/25246?src=pr&el=footer). Last update [2448e52...5bd3d4d](https://codecov.io/gh/pandas-dev/pandas/pull/25246?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/25246?src=pr&el=h1) Report
> Merging [#25246](https://codecov.io/gh/pandas-dev/pandas/pull/25246?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2448e5229683acbe7de57f2d53065247aa085b1f?src=pr&el=desc) will **increase** coverage by `0.03%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #25246      +/-   ##
==========================================
+ Coverage    91.9%   91.93%   +0.03%     
==========================================
  Files         166      166              
  Lines       52213    52182      -31     
==========================================
- Hits        47985    47974      -11     
+ Misses       4228     4208      -20
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.47% <100%> (+0.03%)` | :arrow_up: |
| #single | `42.14% <0%> (+0.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25246?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/25246/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.08% <100%> (-0.03%)` | :arrow_down: |
| [pandas/core/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25246/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbWlzc2luZy5weQ==) | `92.56% <100%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25246/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.83% <0%> (+0.09%)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/25246/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.81% <0%> (+0.16%)` | :arrow_up: |
| [pandas/io/formats/console.py](https://codecov.io/gh/pandas-dev/pandas/pull/25246/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvY29uc29sZS5weQ==) | `86.27% <0%> (+19.6%)` | :arrow_up: |

------

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

Hello @nmusolino! Thanks for updating the PR.







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

##### Comment last updated on February 11, 2019 at 12:36 Hours UTC
lgtm. @gfyoung over to you.
Thanks @nmusolino !