Convert Timestamp to DateTime for Pandas DataFrame

To convert a pandas data frame value from unix timestamp to python datetime you need to use:


  • timestamp is the column containing the timestamp value
  • unit='s' defines the unit of the timestamp (seconds in this case)

You can actually replace the column altogether:

Unfortunately, the conversion is not really aware of the time zone so, if you want to e.g. create a django module, you’ll need to make the datetime object aware:

Moreover, if you want to change to another timezone, you’ll need to:

A little experiment: If you find this post and ad below useful, please check the ad out :-)

2 thoughts on “Convert Timestamp to DateTime for Pandas DataFrame

  1. Hi, I’m following this in many forums but the output foe datetime will have +xx:xx behind the hh:mm:ss. Is there a way to add the +xx:xx to the time directly?
    example 06:20:00+08:00 becomes 14:20:00.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top