Skip to content
Merged
Prev Previous commit
Next Next commit
Check for NaN order in spline validation
  • Loading branch information
nmusolino committed Feb 10, 2019
commit 2d5ec0d96958020864a92a4d8dba7e21e498aa12
2 changes: 1 addition & 1 deletion pandas/core/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None,
new_y = terp(new_x)
elif method == 'spline':
# GH #10633, #24014
if order is None or (order <= 0):
if isna(order) or (order <= 0):
raise ValueError("order needs to be specified and greater than 0; "
"got order: {}".format(order))
terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ def test_no_order(self, method):
s.interpolate(method=method)

@td.skip_if_no_scipy
@pytest.mark.parametrize('order', [-1, -1.0, 0, 0.0])
@pytest.mark.parametrize('order', [-1, -1.0, 0, 0.0, np.nan])
def test_interpolate_spline_invalid_order(self, order):
s = Series([0, 1, np.nan, 3])
msg = "order needs to be specified and greater than 0"
Expand Down