I have a pandas Series with values of type datetime64[ns]
. The dates are in EST timezone, and I would like to convert them to UTC timezone.
E.g.,
Update: In recent pandas, you can use the dt accessor to broadcast this:
In [11]: s.dt.tz_localize('UTC')
Out[11]:
0 2012-01-01 01:30:00+00:00
1 2012-01-01 01:31:00+00:00
2 2012-01-01 01:32:00+00:00
dtype: datetime64[ns, UTC]
Here's one way (depending if tz is already set it might be a tz_convert rather than tz_localize):
In [21]: from pandas.lib import Timestamp
In [22]: s.apply(lambda x: x.tz_localize('UTC'))
Out[22]:
0 2012-01-01 06:30:00+00:00
1 2012-01-01 06:31:00+00:00
2 2012-01-01 06:32:00+00:00