diff --git a/pandas/core/common.py b/pandas/core/common.py index c0432b53e346a..8791dcc124a6e 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -1392,7 +1392,7 @@ def backfill_2d(values, limit=None, mask=None, dtype=None): def _clean_interp_method(method, order=None, **kwargs): - valid = ['linear', 'time', 'values', 'nearest', 'zero', 'slinear', + valid = ['linear', 'time', 'index', 'values', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'barycentric', 'polynomial', 'krogh', 'piecewise_polynomial', 'pchip', 'spline'] @@ -1457,7 +1457,7 @@ def _interp_limit(invalid, limit): result.fill(np.nan) return result - if method in ['linear', 'time', 'values']: + if method in ['linear', 'time', 'index', 'values']: if method in ('values', 'index'): inds = np.asarray(xvalues) # hack for DatetimeIndex, #1646 diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 9b1ddc1fcf6f2..59a457229d512 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2532,7 +2532,7 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False, Parameters ---------- - method : {'linear', 'time', 'values', 'index' 'nearest', 'zero', + method : {'linear', 'time', 'index', 'values', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'barycentric', 'krogh', 'polynomial', 'spline' 'piecewise_polynomial', 'pchip'} @@ -2540,7 +2540,7 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False, spaced. default * 'time': interpolation works on daily and higher resolution data to interpolate given length of interval - * 'index': use the actual numerical values of the index + * 'index', 'values': use the actual numerical values of the index * 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'barycentric', 'polynomial' is passed to `scipy.interpolate.interp1d` with the order given both diff --git a/pandas/tests/test_generic.py b/pandas/tests/test_generic.py index 1a123eda601a2..82447635473a3 100644 --- a/pandas/tests/test_generic.py +++ b/pandas/tests/test_generic.py @@ -512,7 +512,7 @@ def test_interpolate_index_values(self): vals = s.index.values.astype(float) - result = s.interpolate(method='values') + result = s.interpolate(method='index') expected = s.copy() bad = isnull(expected.values) @@ -522,6 +522,12 @@ def test_interpolate_index_values(self): assert_series_equal(result[bad], expected) + # 'values' is synonymous with 'index' for the method kwarg + other_result = s.interpolate(method='values') + + assert_series_equal(other_result, result) + assert_series_equal(other_result[bad], expected) + def test_interpolate_non_ts(self): s = Series([1, 3, np.nan, np.nan, np.nan, 11]) with tm.assertRaises(ValueError):