|
12 | 12 |
|
13 | 13 | class TestDatetimeIndex(tm.TestCase):
|
14 | 14 |
|
| 15 | + def test_construction_caching(self): |
| 16 | + |
| 17 | + df = pd.DataFrame({'dt': pd.date_range('20130101', periods=3), |
| 18 | + 'dttz': pd.date_range('20130101', periods=3, |
| 19 | + tz='US/Eastern'), |
| 20 | + 'dt_with_null': [pd.Timestamp('20130101'), pd.NaT, |
| 21 | + pd.Timestamp('20130103')], |
| 22 | + 'dtns': pd.date_range('20130101', periods=3, |
| 23 | + freq='ns')}) |
| 24 | + assert df.dttz.dtype.tz.zone == 'US/Eastern' |
| 25 | + |
15 | 26 | def test_construction_with_alt(self):
|
16 | 27 |
|
17 | 28 | i = pd.date_range('20130101', periods=5, freq='H', tz='US/Eastern')
|
18 | 29 | i2 = DatetimeIndex(i, dtype=i.dtype)
|
19 | 30 | self.assert_index_equal(i, i2)
|
| 31 | + assert i.tz.zone == 'US/Eastern' |
20 | 32 |
|
21 | 33 | i2 = DatetimeIndex(i.tz_localize(None).asi8, tz=i.dtype.tz)
|
22 | 34 | self.assert_index_equal(i, i2)
|
| 35 | + assert i.tz.zone == 'US/Eastern' |
23 | 36 |
|
24 | 37 | i2 = DatetimeIndex(i.tz_localize(None).asi8, dtype=i.dtype)
|
25 | 38 | self.assert_index_equal(i, i2)
|
| 39 | + assert i.tz.zone == 'US/Eastern' |
26 | 40 |
|
27 | 41 | i2 = DatetimeIndex(
|
28 | 42 | i.tz_localize(None).asi8, dtype=i.dtype, tz=i.dtype.tz)
|
29 | 43 | self.assert_index_equal(i, i2)
|
| 44 | + assert i.tz.zone == 'US/Eastern' |
30 | 45 |
|
31 | 46 | # localize into the provided tz
|
32 | 47 | i2 = DatetimeIndex(i.tz_localize(None).asi8, tz='UTC')
|
|
0 commit comments