Skip to content

Commit 03f01c7

Browse files
committed
BUG: 10633 and 10800 fix
1 parent fa2378b commit 03f01c7

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

doc/source/whatsnew/v0.17.0.txt

+7
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,18 @@ Performance Improvements
612612

613613
Bug Fixes
614614
~~~~~~~~~
615+
<<<<<<< HEAD
615616
- Bug in ``DataFrame.to_html(index=False)`` renders unnecessary ``name`` row (:issue:`10344`)
617+
=======
618+
619+
620+
- Bug in ``DataFrame.to_html(index=False)`` renders unnecessary ``name`` row (:issue:`10344`)
621+
>>>>>>> updating examples and the bug fix
616622
- Bug in ``DataFrame.apply`` when function returns categorical series. (:issue:`9573`)
617623
- Bug in ``to_datetime`` with invalid dates and formats supplied (:issue:`10154`)
618624
- Bug in ``Index.drop_duplicates`` dropping name(s) (:issue:`10115`)
619625
- Bug in ``pd.Series`` when setting a value on an empty ``Series`` whose index has a frequency. (:issue:`10193`)
626+
- 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`)
620627
- Bug in ``DataFrame.plot`` raises ``ValueError`` when color name is specified by multiple characters (:issue:`10387`)
621628
- Bug in ``Index`` construction with a mixed list of tuples (:issue:`10697`)
622629
- Bug in ``DataFrame.reset_index`` when index contains `NaT`. (:issue:`10388`)

pandas/core/common.py

+17
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,23 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None,
17181718
bounds_error=bounds_error)
17191719
new_y = terp(new_x)
17201720
elif method == 'spline':
1721+
<<<<<<< HEAD
1722+
1723+
# GH #10633: first attempt
1724+
<<<<<<< HEAD
1725+
1726+
if not order:
1727+
raise ValueError("order needs to be specified and greater than 0")
1728+
1729+
=======
1730+
if order is None:
1731+
raise ValueError("order needs to be specified, use 1, 2, or 3")
1732+
>>>>>>> 1561f91... small changes
1733+
=======
1734+
# GH #10633
1735+
if not order:
1736+
raise ValueError("order needs to be specified and greater than 0")
1737+
>>>>>>> 5a5407e... updating examples and the bug fix
17211738
terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs)
17221739
new_y = terp(new_x)
17231740
else:

pandas/tests/test_generic.py

+51
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,40 @@ def test_nan_interpolate(self):
799799
tm._skip_if_no_scipy()
800800
result = s.interpolate(method='polynomial', order=1)
801801
assert_series_equal(result, expected)
802+
<<<<<<< HEAD
803+
<<<<<<< HEAD
804+
805+
# GH #10633
806+
=======
807+
# GH #10633: first attempt
808+
>>>>>>> d992cd0... Updated test
809+
=======
810+
811+
# GH #10633
812+
>>>>>>> 5a5407e... updating examples and the bug fix
813+
def test_interpolate_spline(self):
814+
np.random.seed(1)
815+
s = pd.Series(np.arange(10)**2)
816+
s[np.random.randint(0,9,3)] = np.nan
817+
with tm.assertRaises(ValueError):
818+
s.interpolate(method='spline')
819+
<<<<<<< HEAD
820+
<<<<<<< HEAD
821+
=======
822+
>>>>>>> 027a5e7... Updating based on feedback
823+
824+
def test_interpolate_spline(self):
825+
np.random.seed(1)
826+
t = pd.Series(np.arange(10)**2)
827+
t[np.random.randint(0,9,3)] = np.nan
828+
with tm.assertRaises(ValueError):
829+
t.interpolate(method='spline', order=0)
830+
<<<<<<< HEAD
831+
=======
832+
>>>>>>> d992cd0... Updated test
833+
=======
834+
>>>>>>> 027a5e7... Updating based on feedback
835+
802836

803837
def test_nan_irregular_index(self):
804838
s = Series([1, 2, np.nan, 4], index=[1, 3, 5, 9])
@@ -1398,6 +1432,23 @@ def test_no_order(self):
13981432
s.interpolate(method='polynomial')
13991433
with tm.assertRaises(ValueError):
14001434
s.interpolate(method='spline')
1435+
1436+
<<<<<<< HEAD
1437+
<<<<<<< HEAD
1438+
=======
1439+
# GH #10633
1440+
def test_order_spline_interpolation(self):
1441+
tm._skip_if_no_scipy()
1442+
np.random.seed(1)
1443+
s = Series(np.arange(10)**2)
1444+
s[np.random.randint(0,9,3)] = np.nan
1445+
result1 = s.interpolate(method='spline', order=1)
1446+
expected1 = s.interpolate(method='spline', order=1)
1447+
assert_series_equal(result1, expected1)
1448+
>>>>>>> 5a5407e... updating examples and the bug fix
1449+
=======
1450+
>>>>>>> 027a5e7... Updating based on feedback
1451+
14011452

14021453
def test_spline(self):
14031454
tm._skip_if_no_scipy()

0 commit comments

Comments
 (0)