Skip to content
Advertisement

How to read 24:00 hour?

I have a csv file with 24:00 hour instead of 00:00 and try to read it with pandas. I found solution and try to adopt it. The problem is, I get an error and don’t know how to fix it. Can someone help me?

My csv:

JavaScript

The code I got from the link above adopted to my case:

JavaScript

The error I get:

JavaScript

The link where I got the function to transform it:

Pandas: parsing 24:00 instead of 00:00

Advertisement

Answer

You can use str.split()+pd.to_datetime()+pd.to_timedelta():

JavaScript

OR

JavaScript

output of df:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement