Skip to content

Commit fbf587f

Browse files
author
John David Reaver
committed
DOC: fix docstring for DataFrame.interpolate
1 parent 3a7caf9 commit fbf587f

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

pandas/core/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ def backfill_2d(values, limit=None, mask=None, dtype=None):
13921392

13931393

13941394
def _clean_interp_method(method, order=None, **kwargs):
1395-
valid = ['linear', 'time', 'values', 'nearest', 'zero', 'slinear',
1395+
valid = ['linear', 'time', 'index', 'values', 'nearest', 'zero', 'slinear',
13961396
'quadratic', 'cubic', 'barycentric', 'polynomial',
13971397
'krogh', 'piecewise_polynomial',
13981398
'pchip', 'spline']
@@ -1457,7 +1457,7 @@ def _interp_limit(invalid, limit):
14571457
result.fill(np.nan)
14581458
return result
14591459

1460-
if method in ['linear', 'time', 'values']:
1460+
if method in ['linear', 'time', 'index', 'values']:
14611461
if method in ('values', 'index'):
14621462
inds = np.asarray(xvalues)
14631463
# hack for DatetimeIndex, #1646

pandas/core/generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2532,15 +2532,15 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
25322532
25332533
Parameters
25342534
----------
2535-
method : {'linear', 'time', 'values', 'index' 'nearest', 'zero',
2535+
method : {'linear', 'time', 'index', 'values', 'nearest', 'zero',
25362536
'slinear', 'quadratic', 'cubic', 'barycentric', 'krogh',
25372537
'polynomial', 'spline' 'piecewise_polynomial', 'pchip'}
25382538
25392539
* 'linear': ignore the index and treat the values as equally
25402540
spaced. default
25412541
* 'time': interpolation works on daily and higher resolution
25422542
data to interpolate given length of interval
2543-
* 'index': use the actual numerical values of the index
2543+
* 'index', 'values': use the actual numerical values of the index
25442544
* 'nearest', 'zero', 'slinear', 'quadratic', 'cubic',
25452545
'barycentric', 'polynomial' is passed to
25462546
`scipy.interpolate.interp1d` with the order given both

pandas/tests/test_generic.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def test_interpolate_index_values(self):
512512

513513
vals = s.index.values.astype(float)
514514

515-
result = s.interpolate(method='values')
515+
result = s.interpolate(method='index')
516516

517517
expected = s.copy()
518518
bad = isnull(expected.values)
@@ -522,6 +522,12 @@ def test_interpolate_index_values(self):
522522

523523
assert_series_equal(result[bad], expected)
524524

525+
# 'values' is synonymous with 'index' for the method kwarg
526+
other_result = s.interpolate(method='values')
527+
528+
assert_series_equal(other_result, result)
529+
assert_series_equal(other_result[bad], expected)
530+
525531
def test_interpolate_non_ts(self):
526532
s = Series([1, 3, np.nan, np.nan, np.nan, 11])
527533
with tm.assertRaises(ValueError):

0 commit comments

Comments
 (0)