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

Issue

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())?

Solution

from datetime import datetime
from dateutil.tz import *

datetime.now(tzutc())

Answered By – cheesus

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published