BUG: using .dt.tz_localize('UTC') returns a tz-unaware object · Issue #8411 · pandas-dev/pandas (original) (raw)
In [48]: s
Out[48]:
0 1411161507178
1 1411138436009
2 1411123732180
3 1411167606146
4 1411124780140
5 1411159331327
6 1411131745474
7 1411151831454
8 1411152487758
9 1411137160544
Name: 1, dtype: int64
In [49]: pd.DatetimeIndex(pd.to_datetime(s,unit='ms')).tz_localize('UTC').tz_convert('US/Eastern')
Out[49]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2014-09-19 17🔞27.178000-04:00, ..., 2014-09-19 10:32:40.544000-04:00]
Length: 10, Freq: None, Timezone: US/Eastern
Which should be equivalent to
In [50]: pd.to_datetime(s,unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
TypeError: Cannot convert tz-naive timestamps, use tz_localize to localize