Skip to content Skip to sidebar Skip to footer

Datetime To Iso 8601 In Python

I have this dataframe: How do I change the dttm_utc into ISO8601 format with timezone offset?

Solution 1:

If your object is a datetime object, you can directly convert it to ISO using obj.isoformat(). If your object is not a datetime object, you can convert it using strptime.

Say, if you were using pandas:

my_obj['dttm_iso8601'] = datetime.datetime.strptime(
        my_obj['dttm_utc'],
        '%Y-%m-%s %h:%m:%s'
    ).isoformat()

Post a Comment for "Datetime To Iso 8601 In Python"