

def test_tshift(self):
    ps = tm.makePeriodSeries()
    shifted = ps.tshift(1)
    unshifted = shifted.tshift((- 1))
    assert_series_equal(unshifted, ps)
    shifted2 = ps.tshift(freq='B')
    assert_series_equal(shifted, shifted2)
    shifted3 = ps.tshift(freq=datetools.bday)
    assert_series_equal(shifted, shifted3)
    self.assertRaises(ValueError, ps.tshift, freq='M')
    shifted = self.ts.tshift(1)
    unshifted = shifted.tshift((- 1))
    assert_series_equal(self.ts, unshifted)
    shifted2 = self.ts.tshift(freq=self.ts.index.freq)
    assert_series_equal(shifted, shifted2)
    inferred_ts = Series(self.ts.values, Index(np.asarray(self.ts.index)), name='ts')
    shifted = inferred_ts.tshift(1)
    unshifted = shifted.tshift((- 1))
    assert_series_equal(shifted, self.ts.tshift(1))
    assert_series_equal(unshifted, inferred_ts)
    no_freq = self.ts[[0, 5, 7]]
    self.assertRaises(ValueError, no_freq.tshift)

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