Skip to content

Commit

Permalink
STEP pandas-dev#2 added interpolate_at() and interpolate_na() on top …
Browse files Browse the repository at this point in the history
…of interpolate(), some error handling and filtering may be missing, testing is not done yet
  • Loading branch information
den-run-ai committed Sep 7, 2015
1 parent 340da19 commit 8e7db2a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import copy
import copy
import itertools
import re
import operator
Expand Down Expand Up @@ -745,10 +745,18 @@ def putmask(self, mask, new, align=True, inplace=False,

return [make_block(new_values, placement=self.mgr_locs, fastpath=True)]

def interpolate(self, method='pad', axis=0, index=None,
def interpolate_na(self, inplace=False, **kwargs):
return self.interpolate(new_idxs=None, inplace=inplace, **kwargs)

def interpolate_at(self, new_idxs, **kwargs):
#TODO: check dupes, nans, unique idx
return self.interpolate(new_idxs=new_idxs,inplace=False,**kwargs)

def interpolate(self, new_idxs=None, method='pad', axis=0, index=None,
values=None, inplace=False, limit=None,
fill_value=None, coerce=False, downcast=None, **kwargs):

if inplace and new_idxs:
raise ValueError('inplace=True and new_idxs not empty are incompatible options')
def check_int_bool(self, inplace):
# Only FloatBlocks will contain NaNs.
# timedelta subclasses IntBlock
Expand Down Expand Up @@ -785,7 +793,8 @@ def check_int_bool(self, inplace):
r = check_int_bool(self, inplace)
if r is not None:
return r
return self._interpolate(method=m,
return self._interpolate(new_idxs=new_idxs,
method=m,
index=index,
values=values,
axis=axis,
Expand Down Expand Up @@ -827,7 +836,7 @@ def _interpolate_with_fill(self, method='pad', axis=0, inplace=False,
fastpath=True, placement=self.mgr_locs)]
return self._maybe_downcast(blocks, downcast)

def _interpolate(self, method=None, index=None, values=None,
def _interpolate(self, new_idxs=None, method=None, index=None, values=None,
fill_value=None, axis=0, limit=None,
inplace=False, downcast=None, **kwargs):
""" interpolate using scipy wrappers """
Expand All @@ -854,7 +863,7 @@ def func(x):
# process a 1-d slice, returning it
# should the axis argument be handled below in apply_along_axis?
# i.e. not an arg to com.interpolate_1d
return com.interpolate_1d(index, x, method=method, limit=limit,
return com.interpolate_1d(index, x, new_idxs=new_idxs, method=method, limit=limit,
fill_value=fill_value,
bounds_error=False, **kwargs)

Expand Down

0 comments on commit 8e7db2a

Please sign in to comment.