diff --git a/doc/source/whatsnew/v0.17.0.txt b/doc/source/whatsnew/v0.17.0.txt index 77130343c9d57..0bb2ba3f9b343 100644 --- a/doc/source/whatsnew/v0.17.0.txt +++ b/doc/source/whatsnew/v0.17.0.txt @@ -674,11 +674,18 @@ Performance Improvements Bug Fixes ~~~~~~~~~ +<<<<<<< HEAD - Bug in ``DataFrame.to_html(index=False)`` renders unnecessary ``name`` row (:issue:`10344`) +======= + + +- Bug in ``DataFrame.to_html(index=False)`` renders unnecessary ``name`` row (:issue:`10344`) +>>>>>>> updating examples and the bug fix - Bug in ``DataFrame.apply`` when function returns categorical series. (:issue:`9573`) - Bug in ``to_datetime`` with invalid dates and formats supplied (:issue:`10154`) - Bug in ``Index.drop_duplicates`` dropping name(s) (:issue:`10115`) - Bug in ``pd.Series`` when setting a value on an empty ``Series`` whose index has a frequency. (:issue:`10193`) +- Bug in ``pd.Series.interpolate`` when setting no order value on ``Series.interpolate`` this needs to be at least 1. (:issue:`10633`) and (:issue:`10800`) - Bug in ``DataFrame.plot`` raises ``ValueError`` when color name is specified by multiple characters (:issue:`10387`) - Bug in ``Index`` construction with a mixed list of tuples (:issue:`10697`) - Bug in ``DataFrame.reset_index`` when index contains `NaT`. (:issue:`10388`) diff --git a/pandas/core/common.py b/pandas/core/common.py index 53cd5ca9aa78b..0d74a4449a5f5 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -1718,6 +1718,9 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, bounds_error=bounds_error) new_y = terp(new_x) elif method == 'spline': + # GH #10633 + if not order: + raise ValueError("order needs to be specified and greater than 0") terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs) new_y = terp(new_x) else: diff --git a/pandas/tests/test_generic.py b/pandas/tests/test_generic.py index c1f6045c61d54..b001386466213 100644 --- a/pandas/tests/test_generic.py +++ b/pandas/tests/test_generic.py @@ -799,6 +799,40 @@ def test_nan_interpolate(self): tm._skip_if_no_scipy() result = s.interpolate(method='polynomial', order=1) assert_series_equal(result, expected) +<<<<<<< HEAD +<<<<<<< HEAD + + # GH #10633 +======= + # GH #10633: first attempt +>>>>>>> d992cd0... Updated test +======= + + # GH #10633 +>>>>>>> 5a5407e... updating examples and the bug fix + def test_interpolate_spline(self): + np.random.seed(1) + s = pd.Series(np.arange(10)**2) + s[np.random.randint(0,9,3)] = np.nan + with tm.assertRaises(ValueError): + s.interpolate(method='spline') +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 027a5e7... Updating based on feedback + + def test_interpolate_spline(self): + np.random.seed(1) + t = pd.Series(np.arange(10)**2) + t[np.random.randint(0,9,3)] = np.nan + with tm.assertRaises(ValueError): + t.interpolate(method='spline', order=0) +<<<<<<< HEAD +======= +>>>>>>> d992cd0... Updated test +======= +>>>>>>> 027a5e7... Updating based on feedback + def test_nan_irregular_index(self): s = Series([1, 2, np.nan, 4], index=[1, 3, 5, 9]) @@ -1398,6 +1432,23 @@ def test_no_order(self): s.interpolate(method='polynomial') with tm.assertRaises(ValueError): s.interpolate(method='spline') + +<<<<<<< HEAD +<<<<<<< HEAD +======= + # GH #10633 + def test_order_spline_interpolation(self): + tm._skip_if_no_scipy() + np.random.seed(1) + s = Series(np.arange(10)**2) + s[np.random.randint(0,9,3)] = np.nan + result1 = s.interpolate(method='spline', order=1) + expected1 = s.interpolate(method='spline', order=1) + assert_series_equal(result1, expected1) +>>>>>>> 5a5407e... updating examples and the bug fix +======= +>>>>>>> 027a5e7... Updating based on feedback + def test_spline(self): tm._skip_if_no_scipy()