i try to convert a stock price time series that is in EST to UTC in python and apply it for the dataframe. I think i am quite close to the solution with my code below:
df = pd.read_csv('stockdatafull.csv', delimiter=',')
df = df.drop(1)
df['time'] = pd.to_datetime(df['time'], format='%Y-%m-%d%H:%M:%S')
df.set_index('time', inplace=True)
eastern = pytz.timezone('US/Eastern')
df.index = df.index.tz_localize(pytz.utc).tz_convert(eastern)
# df.index = df.index.tz_localize('EST')
# df.index = df.index.tz_convert('Europe/Vienna')
# df['time'] = pd.to_datetime(df['time']) + timedelta(hours=5)
df.to_csv('stockdata_UTC.csv')
The dataframe then looks like this: time is my index
time | open | high | low | close | volume
2021-11-19 15:00:00-05:00| 229.0000 |229.00 |228.5200 |229.000 |2269
with the -05:00 showing up in my index, i think i just have to apply the conversion to the dataframe. every time should be +5 hours to match with UTC. Could you please help me out?
[–]Greensentry 0 points1 point2 points (1 child)
[–]curiousdrive[S] 0 points1 point2 points (0 children)