Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Read CSV in Python with date column

I want to load a csv into python. Out of the 54 columns in the .csv, I definetly now that some of those are date columns.

However, after reading the csv in the python environment with pandas

df = pd.read_csv("foo.csv", encoding="utf-8")

the colums that are supposed to have dates in it, are filled with really large numbers like 997513068000, 1549627447000, 1655482531000.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I first thought that those might be ordinal dates and I can convert them to calendar dates with datetime.fromordinal(). However, those numbers are way to large to be ordinal dates.

Any idea on what those large numbers in the date columns mean and how I can convert them to normal dates?

>Solution :

Almoast certainly this is an epoch time, likely in milliseconds. Use this resource to easily see what it is in a normal date.

In code, use the python datetime modules fromtimestamp() to get dates from epoch

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading