|
4 | 4 | import operator
|
5 | 5 |
|
6 | 6 | import pytest
|
7 |
| - |
| 7 | +import pytz |
8 | 8 | import numpy as np
|
9 | 9 |
|
10 | 10 | import pandas as pd
|
@@ -476,6 +476,28 @@ def test_dti_shift_localized(self, tzstr):
|
476 | 476 | result = dr_tz.shift(1, '10T')
|
477 | 477 | assert result.tz == dr_tz.tz
|
478 | 478 |
|
| 479 | + def test_dti_shift_across_dst(self): |
| 480 | + # GH 8616 |
| 481 | + idx = date_range('2013-11-03', tz='America/Chicago', |
| 482 | + periods=7, freq='H') |
| 483 | + s = Series(index=idx[:-1]) |
| 484 | + result = s.shift(freq='H') |
| 485 | + expected = Series(index=idx[1:]) |
| 486 | + tm.assert_series_equal(result, expected) |
| 487 | + |
| 488 | + @pytest.mark.parametrize('shift, result_time', [ |
| 489 | + [0, '2014-11-14 00:00:00'], |
| 490 | + [-1, '2014-11-13 23:00:00'], |
| 491 | + [1, '2014-11-14 01:00:00']]) |
| 492 | + def test_dti_shift_near_midnight(self, shift, result_time): |
| 493 | + # GH 8616 |
| 494 | + dt = datetime(2014, 11, 14, 0) |
| 495 | + dt_est = pytz.timezone('EST').localize(dt) |
| 496 | + s = Series(data=[1], index=[dt_est]) |
| 497 | + result = s.shift(shift, freq='H') |
| 498 | + expected = Series(1, index=DatetimeIndex([result_time], tz='EST')) |
| 499 | + tm.assert_series_equal(result, expected) |
| 500 | + |
479 | 501 | # -------------------------------------------------------------
|
480 | 502 | # Binary operations DatetimeIndex and timedelta-like
|
481 | 503 |
|
|
0 commit comments