

def test_pct_change(self):
    rs = self.ts.pct_change(fill_method=None)
    assert_series_equal(rs, ((self.ts / self.ts.shift(1)) - 1))
    rs = self.ts.pct_change(2)
    filled = self.ts.fillna(method='pad')
    assert_series_equal(rs, ((filled / filled.shift(2)) - 1))
    rs = self.ts.pct_change(fill_method='bfill', limit=1)
    filled = self.ts.fillna(method='bfill', limit=1)
    assert_series_equal(rs, ((filled / filled.shift(1)) - 1))
    rs = self.ts.pct_change(freq='5D')
    filled = self.ts.fillna(method='pad')
    assert_series_equal(rs, ((filled / filled.shift(freq='5D')) - 1))

dataset/ETHPy150Open pydata/pandas/pandas/tests/series/test_timeseries.py TestSeriesTimeSeries.test_pct_change/original