diff --git a/doc/source/release.rst b/doc/source/release.rst index 2d9b3649b6f22..de4cea17f6d99 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -338,6 +338,8 @@ pandas 0.12 - Fixed the legend displaying in ``DataFrame.plot(kind='kde')`` (:issue:`4216`) - Fixed bug where Index slices weren't carrying the name attribute (:issue:`4226`) + - Fixed bug in initializing ``DatetimeIndex`` with an array of strings + in a certain time zone (:issue:`4229`) pandas 0.11.0 ============= diff --git a/doc/source/v0.12.0.txt b/doc/source/v0.12.0.txt index f913ebce33082..25813ae026f36 100644 --- a/doc/source/v0.12.0.txt +++ b/doc/source/v0.12.0.txt @@ -471,7 +471,9 @@ Bug Fixes - Fixed the legend displaying in ``DataFrame.plot(kind='kde')`` (:issue:`4216`) - Fixed bug where Index slices weren't carrying the name attribute (:issue:`4226`) - + - Fixed bug in initializing ``DatetimeIndex`` with an array of strings + in a certain time zone (:issue:`4229`) + See the :ref:`full release notes ` or issue tracker on GitHub for a complete list. diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index b133939c2b404..9983f12bb29f0 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -208,9 +208,10 @@ def __new__(cls, data=None, return data if issubclass(data.dtype.type, basestring): - subarr = _str_to_dt_array(data, offset, dayfirst=dayfirst, + data = _str_to_dt_array(data, offset, dayfirst=dayfirst, yearfirst=yearfirst) - elif issubclass(data.dtype.type, np.datetime64): + + if issubclass(data.dtype.type, np.datetime64): if isinstance(data, DatetimeIndex): if tz is None: tz = data.tz diff --git a/pandas/tseries/tests/test_timezones.py b/pandas/tseries/tests/test_timezones.py index e57b554b7ca3c..09224d0133e3d 100644 --- a/pandas/tseries/tests/test_timezones.py +++ b/pandas/tseries/tests/test_timezones.py @@ -631,6 +631,22 @@ def test_index_drop_dont_lose_tz(self): self.assertTrue(ind.tz is not None) + def test_datetimeindex_tz(self): + """ Test different DatetimeIndex constructions with timezone + Follow-up of #4229 + """ + + arr = ['11/10/2005 08:00:00', '11/10/2005 09:00:00'] + + idx1 = to_datetime(arr).tz_localize('US/Eastern') + idx2 = DatetimeIndex(start="2005-11-10 08:00:00", freq='H', periods=2, tz='US/Eastern') + idx3 = DatetimeIndex(arr, tz='US/Eastern') + idx4 = DatetimeIndex(np.array(arr), tz='US/Eastern') + + for other in [idx2, idx3, idx4]: + self.assert_(idx1.equals(other)) + + class TestTimeZones(unittest.TestCase): _multiprocess_can_split_ = True