How to calculate difference in time of a dataset in python

909 Views Asked by At

Hi I am trying to calculate time differences for certain tasks in some data I am working on. I have a csv file with a bunch of data, the relevant columns look like below:

ID Start Date End Date
123456 10/08/2021 02:00:05 AM 10/11/2021 01:00:15 AM
324524 10/11/2021 01:00:15 AM 10/08/2021 02:00:05 AM

My goal is to create a new file with the row ID, the start date, end date, and the time difference in hours.

So far I have used pandas.to_datetime to change the format of the start date and the end date. Now I am wondering how I can calculate the difference between the two times i.e. (end date - start date) in hours and create a new column in the dataframe to store it in.

0

There are 0 best solutions below