Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: using .dt.tz_localize('UTC') returns a tz-unaware object #8411

Closed
jreback opened this issue Sep 28, 2014 · 0 comments · Fixed by #8415
Closed

BUG: using .dt.tz_localize('UTC') returns a tz-unaware object #8411

jreback opened this issue Sep 28, 2014 · 0 comments · Fixed by #8415
Labels
Bug Timezones Timezone data dtype
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Sep 28, 2014

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:18: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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Timezones Timezone data dtype
Projects
None yet
1 participant