cheesus
cheesus

Reputation: 1181

Changing Timestamps from tz='UTC' to tz='tzutc()'

I have a series from an API call and it gives me the index in the format

timeseries.index.values[0]

>>> Timestamp('2019-10-25 15:33:26.068569856+0000', tz='tzutc()')

Then I'm appending some data with the timestamp: datetime.utcnow().replace(tzinfo=pytz.UTC), which, sadly, has another format

timeseries.index.values[-1]

>>> Timestamp('2019-10-25 15:33:27.388853+0000', tz='UTC')] 

Which will cause some errors down the road. How can I create a timestamp thats in the original format (tz='tzutc())?

Upvotes: 1

Views: 1328

Answers (1)

cheesus
cheesus

Reputation: 1181

from datetime import datetime
from dateutil.tz import *

datetime.now(tzutc())

Upvotes: 2

Related Questions