Reputation: 33
I have 2 Panda data frame columns in datetime format and want to get the time difference in minutes. with my code, I get output (output type is "timedelta64[ns]") with days and hours, etc. How can I get it in minutes? Thank you
df['TIME_TO_REPORT']= df['TEST_TIME'] - df['RECEIPT_DATE_TIME']
Output
0 0 days 05:58:00
1 0 days 03:46:00
2 0 days 05:25:00
3 0 days 05:24:00
4 0 days 05:24:00
Upvotes: 1
Views: 84
Reputation: 5433
Use total_seconds
to get the time duration in seconds, and then divide by 60 to convert it to minutes
df['TIME_TO_REPORT']= (df['TEST_TIME'] - df['RECEIPT_DATE_TIME']).dt.total_seconds() / 60
Upvotes: 1