Skip to content

DOC: fix docstring for DataFrame.interpolate #7553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2532,15 +2532,15 @@ 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'}

* 'linear': ignore the index and treat the values as equally
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
Expand Down
8 changes: 7 additions & 1 deletion pandas/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down