I have a dataframe with EPOCH Time in nanoseconds that I would like to convert to Eastern Standard Time format. I use something like:
df['EST'] = pd.to_datetime(df['EPOCH'], unit="ns", utc=True).dt.tz_convert('US/Eastern')
Returns for example:
05-24-2021 13:05:53.631347-04:00
I would like to get rid of the -04:00
so I do something like:
df['EST'] = pd.to_datetime(df['EPOCH'], unit="ns", utc=True).dt.tz_convert('US/Eastern').dt.strftime('%m-%d-%Y %H:%M:%S.%f')
Output is now something like (which is my desired output):
05-24-2021 13:05:53.631347
Is this the best way to do this? Or is there a more efficient way to do it? It seems like I am doing a lot of conversion, so not sure if its the most efficient.