BUG: Index with integer data and datetime64[ns, tz] dtype does not localize correctly · Issue #20964 · pandas-dev/pandas (original) (raw)
In [1]: pd.__version__
Out[1]: '0.23.0rc2+16.gccf4b96.dirty'
In [2]: val = [pd.Timestamp('2018-01-01', tz='US/Pacific').value]
In [3]: pd.Index(val, dtype='datetime64[ns, US/Pacific]')
Out[3]: DatetimeIndex(['2018-01-01 08:00:00-08:00'], dtype='datetime64[ns, US/Pacific]', freq=None)
The localization appears to localize directly to the timezone instead of localizing first to UTC and therefore does not roundtrip correctly from the timestamp value.
#20956 can be simplified once this is fixed.
Expected:
Out[3]: DatetimeIndex(['2018-01-01 00:00:00-08:00'], dtype='datetime64[ns, US/Pacific]', freq=None)