Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
EST to UTC converting in Python and applying to data frame
Post Body

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?

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
7,784
Link Karma
7,336
Comment Karma
448
Profile updated: 1 day ago
Posts updated: 9 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago