How can I convert my datetime column in pandas all to the same timezone How can I convert my datetime column in pandas all to the same timezone pandas pandas

How can I convert my datetime column in pandas all to the same timezone


I think that it is not necessary to apply lambdas:

df_res['DateTime'] = pd.to_datetime(df_res['DateTime'], utc=True)

documentation: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_datetime.html


You can check this:

df = pd.DataFrame({    'time': [        '2017-11-02 19:49:28-08:00',         '2017-11-27 07:32:22-07:00',         '2017-12-27 17:01:15-07:00'    ]})df['time'] = pd.to_datetime(df['time'])df['time'].apply(lambda x: pd.to_datetime(x).tz_localize('US/Eastern'))
0   2017-11-03 03:49:28-04:001   2017-11-27 14:32:22-05:002   2017-12-28 00:01:15-05:00Name: time, dtype: datetime64[ns, US/Eastern]