def test_shift_months(self): s = DatetimeIndex([Timestamp('2000-01-05 00:15:00'), Timestamp('2000-01-31 00:23:00'), Timestamp('2000-01-01'), Timestamp('2000-02-29'), Timestamp('2000-12-31')]) for years in [-1, 0, 1]: for months in [-2, 0, 2]: actual = DatetimeIndex(tslib.shift_months(s.asi8, years * 12 + months)) expected = DatetimeIndex([x + offsets.DateOffset(years=years, months=months) for x in s]) tm.assert_index_equal(actual, expected)
def test_shift_months(self): s = DatetimeIndex([Timestamp('2000-01-05 00:15:00'), Timestamp( '2000-01-31 00:23:00'), Timestamp('2000-01-01'), Timestamp( '2000-02-29'), Timestamp('2000-12-31')]) for years in [-1, 0, 1]: for months in [-2, 0, 2]: actual = DatetimeIndex(tslib.shift_months(s.asi8, years * 12 + months)) expected = DatetimeIndex([x + offsets.DateOffset( years=years, months=months) for x in s]) tm.assert_index_equal(actual, expected)