I have epochs in a pandas series:
0 1654769460000
1 1654772040000
2 1654774680000
3 1654776000000
4 1654776420000
...
2050 1655423700000
2051 1655423760000
2052 1655423820000
2053 1655423880000
2054 1655423940000
Name: t, Length: 2055, dtype: int64
I then convert them to pandas datetimes:
time_stamp = pd.to_datetime(final_df['t'], unit='ms')
My timezone is UTC - 4 so it's the wrong time. I need the time in NYC.
I try to print the following:
print(time_stamp.tz_localize('UTC').tz_convert('America/New_York'))
But it returns nothing - not even an error. What am I doing wrong?
CodePudding user response:
Use .dt.tz_convert
df['tEST'] = pd.to_datetime(df['t'], utc=True, unit='ms').dt.tz_convert('America/New_York')