1

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
Dani Mesejo
  • 61,499
  • 6
  • 49
  • 76
lasan13
  • 19
  • 6
  • 1
    I think there is not implemented to do this directly. You will need to calculate it based on your delta. https://stackoverflow.com/a/14190143/12340367 – Snake_py Nov 09 '21 at 12:00

1 Answers1

1

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
Rodalm
  • 5,169
  • 5
  • 21