def test_interp_limit_direction(self):
        # These tests are for issue #9218 -- fill NaNs in both directions.
        s = Series([1, 3, np.nan, np.nan, np.nan, 11])

        expected = Series([1., 3., np.nan, 7., 9., 11.])
        result = s.interpolate(method='linear', limit=2,
                               limit_direction='backward')
        assert_series_equal(result, expected)

        expected = Series([1., 3., 5., np.nan, 9., 11.])
        result = s.interpolate(method='linear', limit=1,
                               limit_direction='both')
        assert_series_equal(result, expected)

        # Check that this works on a longer series of nans.
        s = Series([1, 3, np.nan, np.nan, np.nan, 7, 9, np.nan, np.nan, 12,
                    np.nan])

        expected = Series([1., 3., 4., 5., 6., 7., 9., 10., 11., 12., 12.])
        result = s.interpolate(method='linear', limit=2,
                               limit_direction='both')
        assert_series_equal(result, expected)

        expected = Series([1., 3., 4., np.nan, 6., 7., 9., 10., 11., 12., 12.])
        result = s.interpolate(method='linear', limit=1,
                               limit_direction='both')
        assert_series_equal(result, expected)
Example #2
0
 def test_no_order(self):
     _skip_if_no_scipy()
     s = Series([0, 1, np.nan, 3])
     with tm.assertRaises(ValueError):
         s.interpolate(method='polynomial')
     with tm.assertRaises(ValueError):
         s.interpolate(method='spline')
    def test_spline_interpolation(self):
        tm._skip_if_no_scipy()

        s = Series(np.arange(10) ** 2)
        s[np.random.randint(0, 9, 3)] = np.nan
        result1 = s.interpolate(method='spline', order=1)
        expected1 = s.interpolate(method='spline', order=1)
        assert_series_equal(result1, expected1)
Example #4
0
    def test_interp_all_good(self):
        s = Series([1, 2, 3])
        result = s.interpolate(method='polynomial', order=1)
        assert_series_equal(result, s)

        # non-scipy
        result = s.interpolate()
        assert_series_equal(result, s)
Example #5
0
    def test_spline_extrapolate(self):
        s = Series([1, 2, 3, 4, np.nan, 6, np.nan])
        result3 = s.interpolate(method='spline', order=1, ext=3)
        expected3 = Series([1., 2., 3., 4., 5., 6., 6.])
        assert_series_equal(result3, expected3)

        result1 = s.interpolate(method='spline', order=1, ext=0)
        expected1 = Series([1., 2., 3., 4., 5., 6., 7.])
        assert_series_equal(result1, expected1)
Example #6
0
    def test_nan_interpolate(self):
        s = Series([0, 1, np.nan, 3])
        result = s.interpolate()
        expected = Series([0, 1, 2, 3])
        assert_series_equal(result, expected)

        _skip_if_no_scipy()
        result = s.interpolate(method='polynomial', order=1)
        assert_series_equal(result, expected)
Example #7
0
    def test_interp_scipy_basic(self):
        tm._skip_if_no_scipy()
        s = Series([1, 3, np.nan, 12, np.nan, 25])
        # slinear
        expected = Series([1., 3., 7.5, 12., 18.5, 25.])
        result = s.interpolate(method='slinear')
        assert_series_equal(result, expected)

        result = s.interpolate(method='slinear', donwcast='infer')
        assert_series_equal(result, expected)
        # nearest
        expected = Series([1, 3, 3, 12, 12, 25])
        result = s.interpolate(method='nearest')
        assert_series_equal(result, expected.astype('float'))

        result = s.interpolate(method='nearest', downcast='infer')
        assert_series_equal(result, expected)
        # zero
        expected = Series([1, 3, 3, 12, 12, 25])
        result = s.interpolate(method='zero')
        assert_series_equal(result, expected.astype('float'))

        result = s.interpolate(method='zero', downcast='infer')
        assert_series_equal(result, expected)
        # quadratic
        expected = Series([1, 3., 6.769231, 12., 18.230769, 25.])
        result = s.interpolate(method='quadratic')
        assert_series_equal(result, expected)

        result = s.interpolate(method='quadratic', downcast='infer')
        assert_series_equal(result, expected)
        # cubic
        expected = Series([1., 3., 6.8, 12., 18.2, 25.])
        result = s.interpolate(method='cubic')
        assert_series_equal(result, expected)
Example #8
0
    def test_interp_multiIndex(self):
        idx = MultiIndex.from_tuples([(0, 'a'), (1, 'b'), (2, 'c')])
        s = Series([1, 2, np.nan], index=idx)

        expected = s.copy()
        expected.loc[2] = 2
        result = s.interpolate()
        assert_series_equal(result, expected)

        tm._skip_if_no_scipy()
        with tm.assertRaises(ValueError):
            s.interpolate(method='polynomial', order=1)
    def test_spline_extrapolate(self):
        tm.skip_if_no_package(
            'scipy', '0.15',
            'setting ext on scipy.interpolate.UnivariateSpline')
        s = Series([1, 2, 3, 4, np.nan, 6, np.nan])
        result3 = s.interpolate(method='spline', order=1, ext=3)
        expected3 = Series([1., 2., 3., 4., 5., 6., 6.])
        assert_series_equal(result3, expected3)

        result1 = s.interpolate(method='spline', order=1, ext=0)
        expected1 = Series([1., 2., 3., 4., 5., 6., 7.])
        assert_series_equal(result1, expected1)
    def test_interp_limit_forward(self):
        s = Series([1, 3, np.nan, np.nan, np.nan, 11])

        # Provide 'forward' (the default) explicitly here.
        expected = Series([1., 3., 5., 7., np.nan, 11.])

        result = s.interpolate(method='linear', limit=2,
                               limit_direction='forward')
        assert_series_equal(result, expected)

        result = s.interpolate(method='linear', limit=2,
                               limit_direction='FORWARD')
        assert_series_equal(result, expected)
Example #11
0
    def test_interpolate_corners(self):
        s = Series([np.nan, np.nan])
        assert_series_equal(s.interpolate(), s)

        s = Series([]).interpolate()
        assert_series_equal(s.interpolate(), s)

        _skip_if_no_scipy()
        s = Series([np.nan, np.nan])
        assert_series_equal(s.interpolate(method='polynomial', order=1), s)

        s = Series([]).interpolate()
        assert_series_equal(s.interpolate(method='polynomial', order=1), s)
    def test_interp_limit_to_ends(self):
        # These test are for issue #10420 -- flow back to beginning.
        s = Series([np.nan, np.nan, 5, 7, 9, np.nan])

        expected = Series([5., 5., 5., 7., 9., np.nan])
        result = s.interpolate(method='linear', limit=2,
                               limit_direction='backward')
        assert_series_equal(result, expected)

        expected = Series([5., 5., 5., 7., 9., 9.])
        result = s.interpolate(method='linear', limit=2,
                               limit_direction='both')
        assert_series_equal(result, expected)
Example #13
0
    def test_interp_timedelta64(self):
        # GH 6424
        df = Series([1, np.nan, 3],
                    index=pd.to_timedelta([1, 2, 3]))
        result = df.interpolate(method='time')
        expected = Series([1., 2., 3.],
                          index=pd.to_timedelta([1, 2, 3]))
        assert_series_equal(result, expected)

        # test for non uniform spacing
        df = Series([1, np.nan, 3],
                    index=pd.to_timedelta([1, 2, 4]))
        result = df.interpolate(method='time')
        expected = Series([1., 1.666667, 3.],
                          index=pd.to_timedelta([1, 2, 4]))
        assert_series_equal(result, expected)
 def test_interp_datetime64(self):
     tm._skip_if_no_scipy()
     df = Series([1, np.nan, 3], index=date_range('1/1/2000', periods=3))
     result = df.interpolate(method='nearest')
     expected = Series([1., 1., 3.],
                       index=date_range('1/1/2000', periods=3))
     assert_series_equal(result, expected)
Example #15
0
    def adapt_values(self, data, target_timestamps, merged_timestamps):
        timelink = {}
        for i in range(0, len(self.timestamp)):
            timelink[self.timestamp[i]] = data[i]

        length = len(merged_timestamps)
        values = np.zeros(length)
        values[:] = np.NaN

        for i in range(0, length):
            timekey = merged_timestamps[i]

            if timekey in timelink:
                values[i] = timelink[timekey]

        s = Series(data=values)
        s = s.interpolate()

        values = []
        for i in range(0, length):
            timekey = merged_timestamps[i]

            if timekey in target_timestamps:
                values.append(s[i])

        return values
Example #16
0
    def test_interp_unlimited(self):
        # these test are for issue #16282 default Limit=None is unlimited
        s = Series([np.nan, 1., 3., np.nan, np.nan, np.nan, 11., np.nan])
        expected = Series([1., 1., 3., 5., 7., 9., 11., 11.])
        result = s.interpolate(method='linear',
                               limit_direction='both')
        assert_series_equal(result, expected)

        expected = Series([np.nan, 1., 3., 5., 7., 9., 11., 11.])
        result = s.interpolate(method='linear',
                               limit_direction='forward')
        assert_series_equal(result, expected)

        expected = Series([1., 1., 3., 5., 7., 9., 11., np.nan])
        result = s.interpolate(method='linear',
                               limit_direction='backward')
        assert_series_equal(result, expected)
Example #17
0
    def test_interp_limit(self):
        s = Series([1, 3, np.nan, np.nan, np.nan, 11])

        expected = Series([1., 3., 5., 7., np.nan, 11.])
        result = s.interpolate(method='linear', limit=2)
        assert_series_equal(result, expected)

        # GH 9217, make sure limit is an int and greater than 0
        methods = ['linear', 'time', 'index', 'values', 'nearest', 'zero',
                   'slinear', 'quadratic', 'cubic', 'barycentric', 'krogh',
                   'polynomial', 'spline', 'piecewise_polynomial', None,
                   'from_derivatives', 'pchip', 'akima']
        s = pd.Series([1, 2, np.nan, np.nan, 5])
        for limit in [-1, 0, 1., 2.]:
            for method in methods:
                with pytest.raises(ValueError):
                    s.interpolate(limit=limit, method=method)
    def test_interp_limit_before_ends(self):
        # These test are for issue #11115 -- limit ends properly.
        s = Series([np.nan, np.nan, 5, 7, np.nan, np.nan])

        expected = Series([np.nan, np.nan, 5., 7., 7., np.nan])
        result = s.interpolate(method='linear', limit=1,
                               limit_direction='forward')
        assert_series_equal(result, expected)

        expected = Series([np.nan, 5., 5., 7., np.nan, np.nan])
        result = s.interpolate(method='linear', limit=1,
                               limit_direction='backward')
        assert_series_equal(result, expected)

        expected = Series([np.nan, 5., 5., 7., 7., np.nan])
        result = s.interpolate(method='linear', limit=1,
                               limit_direction='both')
        assert_series_equal(result, expected)
Example #19
0
    def test_interpolate_index_values(self):
        s = Series(np.nan, index=np.sort(np.random.rand(30)))
        s[::3] = np.random.randn(10)

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

        result = s.interpolate(method='index')

        expected = s.copy()
        bad = isnull(expected.values)
        good = ~bad
        expected = Series(
            np.interp(vals[bad], vals[good], s.values[good]), index=s.index[bad])

        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)
Example #20
0
    def interpolate(a, target_size):
        length = len(a)
        values = np.zeros(target_size)
        values[:] = np.NaN

        step = target_size / length

        for i in range(0, length):
            values[i * step] = a[i]

        s = Series(data=values)
        s = s.interpolate()

        return s.values
Example #21
0
    def test_interp_scipy_basic(self):
        tm._skip_if_no_scipy()

        s = Series([1, 3, np.nan, 12, np.nan, 25])
        # slinear
        expected = Series([1., 3., 7.5, 12., 18.5, 25.])
        result = s.interpolate(method='slinear')
        assert_series_equal(result, expected)

        result = s.interpolate(method='slinear', downcast='infer')
        assert_series_equal(result, expected)
        # nearest
        expected = Series([1, 3, 3, 12, 12, 25])
        result = s.interpolate(method='nearest')
        assert_series_equal(result, expected.astype('float'))

        result = s.interpolate(method='nearest', downcast='infer')
        assert_series_equal(result, expected)
        # zero
        expected = Series([1, 3, 3, 12, 12, 25])
        result = s.interpolate(method='zero')
        assert_series_equal(result, expected.astype('float'))

        result = s.interpolate(method='zero', downcast='infer')
        assert_series_equal(result, expected)
        # quadratic
        # GH #15662.
        # new cubic and quadratic interpolation algorithms from scipy 0.19.0.
        # previously `splmake` was used. See scipy/scipy#6710
        if _is_scipy_ge_0190:
            expected = Series([1, 3., 6.823529, 12., 18.058824, 25.])
        else:
            expected = Series([1, 3., 6.769231, 12., 18.230769, 25.])
        result = s.interpolate(method='quadratic')
        assert_series_equal(result, expected)

        result = s.interpolate(method='quadratic', downcast='infer')
        assert_series_equal(result, expected)
        # cubic
        expected = Series([1., 3., 6.8, 12., 18.2, 25.])
        result = s.interpolate(method='cubic')
        assert_series_equal(result, expected)
Example #22
0
    def test_interpolate_index_values(self):
        s = Series(np.nan, index=np.sort(np.random.rand(30)))
        s[::3] = np.random.randn(10)

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

        result = s.interpolate(method='values')

        expected = s.copy()
        bad = isnull(expected.values)
        good = -bad
        expected = Series(
            np.interp(vals[bad], vals[good], s.values[good]), index=s.index[bad])

        assert_series_equal(result[bad], expected)
Example #23
0
 def test_nan_str_index(self):
     s = Series([0, 1, 2, np.nan], index=list('abcd'))
     result = s.interpolate()
     expected = Series([0., 1., 2., 2.], index=list('abcd'))
     assert_series_equal(result, expected)
 def test_nan_interpolate(self, kwargs):
     s = Series([0, 1, np.nan, 3])
     result = s.interpolate(**kwargs)
     expected = Series([0.0, 1.0, 2.0, 3.0])
     tm.assert_series_equal(result, expected)
Example #25
0
 def test_interp_quad(self):
     _skip_if_no_scipy()
     sq = Series([1, 4, np.nan, 16], index=[1, 2, 3, 4])
     result = sq.interpolate(method='quadratic')
     expected = Series([1, 4, 9, 16], index=[1, 2, 3, 4])
     assert_series_equal(result, expected)
Example #26
0
 def test_nan_irregular_index(self):
     s = Series([1, 2, np.nan, 4], index=[1, 3, 5, 9])
     result = s.interpolate()
     expected = Series([1, 2, 3, 4], index=[1, 3, 5, 9])
     assert_series_equal(result, expected)
Example #27
0
 def test_interpolate_non_ts(self):
     s = Series([1, 3, np.nan, np.nan, np.nan, 11])
     with tm.assertRaises(ValueError):
         s.interpolate(method='time')
 def test_interp_quad(self):
     sq = Series([1, 4, np.nan, 16], index=[1, 2, 3, 4])
     result = sq.interpolate(method="quadratic")
     expected = Series([1.0, 4.0, 9.0, 16.0], index=[1, 2, 3, 4])
     tm.assert_series_equal(result, expected)
Example #29
0
 def test_interp_nonmono_raise(self):
     tm._skip_if_no_scipy()
     s = Series([1, np.nan, 3], index=[0, 2, 1])
     with tm.assertRaises(ValueError):
         s.interpolate(method='krogh')
Example #30
0
 def test_interp_nonmono_raise(self):
     tm._skip_if_no_scipy()
     s = Series([1, np.nan, 3], index=[0, 2, 1])
     with pytest.raises(ValueError):
         s.interpolate(method='krogh')
Example #31
0
 def test_spline(self):
     tm._skip_if_no_scipy()
     s = Series([1, 2, np.nan, 4, 5, np.nan, 7])
     result = s.interpolate(method='spline', order=1)
     expected = Series([1., 2., 3., 4., 5., 6., 7.])
     assert_series_equal(result, expected)
    def test_interpolate_corners(self, kwargs):
        s = Series([np.nan, np.nan])
        tm.assert_series_equal(s.interpolate(**kwargs), s)

        s = Series([], dtype=object).interpolate()
        tm.assert_series_equal(s.interpolate(**kwargs), s)
Example #33
0
 def test_spline_smooth(self):
     tm._skip_if_no_scipy()
     s = Series([1, 2, np.nan, 4, 5.1, np.nan, 7])
     assert (s.interpolate(method='spline', order=3, s=0)[5] !=
             s.interpolate(method='spline', order=3)[5])
Example #34
0
 def test_interpolate_non_ts(self):
     s = Series([1, 3, np.nan, np.nan, np.nan, 11])
     with pytest.raises(ValueError):
         s.interpolate(method='time')
Example #35
0
 def test_nan_irregular_index(self):
     s = Series([1, 2, np.nan, 4], index=[1, 3, 5, 9])
     result = s.interpolate()
     expected = Series([1., 2., 3., 4.], index=[1, 3, 5, 9])
     assert_series_equal(result, expected)
 def test_interp_nonmono_raise(self):
     s = Series([1, np.nan, 3], index=[0, 2, 1])
     msg = "krogh interpolation requires that the index be monotonic"
     with pytest.raises(ValueError, match=msg):
         s.interpolate(method="krogh")
    def test_interp_limit(self):
        s = Series([1, 3, np.nan, np.nan, np.nan, 11])

        expected = Series([1.0, 3.0, 5.0, 7.0, np.nan, 11.0])
        result = s.interpolate(method="linear", limit=2)
        tm.assert_series_equal(result, expected)
Example #38
0
 def test_interp_limit(self):
     s = Series([1, 3, np.nan, np.nan, np.nan, 11])
     expected = Series([1., 3., 5., 7., np.nan, 11.])
     result = s.interpolate(method='linear', limit=2)
     assert_series_equal(result, expected)
class MySeries:
    def __init__(self, *args, **kwargs):
        self.x = Series(*args, **kwargs)
        self.values = self.x.values
        self.index = self.x.index
    
    def rolling_mean(self, *args, **kwargs):
        return MySeries(pd.rolling_mean(self.x, *args, **kwargs))

    def rolling_count(self, *args, **kwargs):
        return MySeries(pd.rolling_count(self.x, *args, **kwargs))

    def rolling_sum(self, *args, **kwargs):
        return MySeries(pd.rolling_sum(self.x, *args, **kwargs))

    def rolling_median(self, *args, **kwargs):
        return MySeries(pd.rolling_median(self.x, *args, **kwargs))
        
    def rolling_min(self, *args, **kwargs):
        return MySeries(pd.rolling_min(self.x, *args, **kwargs))

    def rolling_max(self, *args, **kwargs):
        return MySeries(pd.rolling_max(self.x, *args, **kwargs))

    def rolling_std(self, *args, **kwargs):
        return MySeries(pd.rolling_std(self.x, *args, **kwargs))

    def rolling_var(self, *args, **kwargs):
        return MySeries(pd.rolling_var(self.x, *args, **kwargs))

    def rolling_skew(self, *args, **kwargs):
        return MySeries(pd.rolling_skew(self.x, *args, **kwargs))

    def rolling_kurtosis(self, *args, **kwargs):
        return MySeries(pd.rolling_kurtosis(self.x, *args, **kwargs))

    def rolling_window(self, *args, **kwargs):
        return MySeries(pd.rolling_window(self.x, *args, **kwargs))

    def cumprod(self, *args, **kwargs):
        return MySeries(self.x.cumprod(*args, **kwargs))

    def cumsum(self, *args, **kwargs):
        return MySeries(self.x.cumsum(*args, **kwargs))

    def diff(self, *args, **kwargs):
        return MySeries(self.x.diff(*args, **kwargs))

    def div(self, *args, **kwargs):
        return MySeries(self.x.div(*args, **kwargs))

    def mul(self, *args, **kwargs):
        return MySeries(self.x.mul(*args, **kwargs))

    def add(self, *args, **kwargs):
        return MySeries(self.x.add(*args, **kwargs))

    def dropna(self, *args, **kwargs):
        return MySeries(self.x.dropna(*args, **kwargs))
    
    def fillna(self, *args, **kwargs):
        return MySeries(self.x.fillna(*args, **kwargs))

    def floordiv(self, *args, **kwargs):
        return MySeries(self.x.floordiv(*args, **kwargs))

    def mod(self, *args, **kwargs):
        return MySeries(self.x.mod(*args, **kwargs))

    def nlargest(self, *args, **kwargs):
        return MySeries(self.x.nlargest(*args, **kwargs))

    def nonzero(self, *args, **kwargs):
        return MySeries(self.x.nonzero(*args, **kwargs))

    def nsmallest(self, *args, **kwargs):
        return MySeries(self.x.nsmallest(*args, **kwargs))

    def pow(self, *args, **kwargs):
        return MySeries(self.x.pow(*args, **kwargs))

    def rank(self, *args, **kwargs):
        return MySeries(self.x.rank(*args, **kwargs))

    def round(self, *args, **kwargs):
        return MySeries(self.x.round(*args, **kwargs))

    def shift(self, *args, **kwargs):
        return MySeries(self.x.shift(*args, **kwargs))

    def sub(self, *args, **kwargs):
        return MySeries(self.x.sub(*args, **kwargs))

    def abs(self, *args, **kwargs):
        return MySeries(self.x.abs(*args, **kwargs))

    def clip(self, *args, **kwargs):
        return MySeries(self.x.clip(*args, **kwargs))

    def clip_lower(self, *args, **kwargs):
        return MySeries(self.x.clip_lower(*args, **kwargs))

    def clip_upper(self, *args, **kwargs):
        return MySeries(self.x.clip_upper(*args, **kwargs))
    
    def interpolate(self, *args, **kwargs):
        return MySeries(self.x.interpolate(*args, **kwargs))

    def resample(self, *args, **kwargs):
        return MySeries(self.x.resample(*args, **kwargs))
        
    def replace(self, *args, **kwargs):
        return MySeries(self.x.replace(*args, **kwargs))
Example #40
0
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pandas import DataFrame, Series
from datetime import datetime

# making TimeSeries with missing values
datestrs = ['6/1/2020','6/3/2020', '6/4/2020', '6/8/2020','6/10/2020']
dates = pd.to_datetime(datestrs)
print(dates)
print("===========")

ts = Series([1, np.nan, np.nan, 8, 10], index = dates)
print(ts)

ts_intp_liner = ts.interpolate()
print(ts_intp_liner)
 def test_spline_interpolation(self):
     s = Series(np.arange(10)**2)
     s[np.random.randint(0, 9, 3)] = np.nan
     result1 = s.interpolate(method="spline", order=1)
     expected1 = s.interpolate(method="spline", order=1)
     tm.assert_series_equal(result1, expected1)
 def test_spline_smooth(self):
     s = Series([1, 2, np.nan, 4, 5.1, np.nan, 7])
     assert (s.interpolate(method="spline", order=3, s=0)[5] !=
             s.interpolate(method="spline", order=3)[5])
 def test_nan_str_index(self):
     s = Series([0, 1, 2, np.nan], index=list("abcd"))
     result = s.interpolate()
     expected = Series([0.0, 1.0, 2.0, 2.0], index=list("abcd"))
     tm.assert_series_equal(result, expected)
 def test_spline(self):
     s = Series([1, 2, np.nan, 4, 5, np.nan, 7])
     result = s.interpolate(method="spline", order=1)
     expected = Series([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0])
     tm.assert_series_equal(result, expected)
Example #45
0
 def test_nan_str_index(self):
     s = Series([0, 1, 2, np.nan], index=list('abcd'))
     result = s.interpolate()
     expected = Series([0, 1, 2, 2], index=list('abcd'))
     assert_series_equal(result, expected)
 def test_interpolate_spline_invalid_order(self, order):
     s = Series([0, 1, np.nan, 3])
     msg = "order needs to be specified and greater than 0"
     with pytest.raises(ValueError, match=msg):
         s.interpolate(method="spline", order=order)
Example #47
0
 def test_interp_limit(self):
     s = Series([1, 3, np.nan, np.nan, np.nan, 11])
     expected = Series([1., 3., 5., 7., np.nan, 11.])
     result = s.interpolate(method='linear', limit=2)
     assert_series_equal(result, expected)
 def test_no_order(self, method):
     # see GH-10633, GH-24014
     s = Series([0, 1, np.nan, 3])
     msg = "You must specify the order of the spline or polynomial"
     with pytest.raises(ValueError, match=msg):
         s.interpolate(method=method)
Example #49
0
 def test_spline(self):
     _skip_if_no_scipy()
     s = Series([1, 2, np.nan, 4, 5, np.nan, 7])
     result = s.interpolate(method='spline', order=1)
     expected = Series([1, 2, 3, 4, 5, 6, 7])
     assert_series_equal(result, expected)
Example #50
0
 def test_interp_quad(self):
     tm._skip_if_no_scipy()
     sq = Series([1, 4, np.nan, 16], index=[1, 2, 3, 4])
     result = sq.interpolate(method='quadratic')
     expected = Series([1., 4., 9., 16.], index=[1, 2, 3, 4])
     assert_series_equal(result, expected)