0

I have this dataframe:

Product   Start Time            End Time
   A      2021-02-03 00:07:43   2021-02-03 00:42:53.000000000   
   B      2021-02-03 00:11:15   2021-02-03 00:13:55.000000000   
   C      2021-02-03 00:13:16   2021-02-03 00:13:16.000000000   
   D      2021-02-03 00:16:48   2021-02-03 00:21:52.000000000   
   E      2021-02-03 00:17:11   2021-02-03 00:31:31.000000000          

I need to do a subtraction between two datetime columns.

df['duration'] = ((df['End time']) - (df['Start Solicitud']))

The result is:

0        0 days 00:02:38
1        0 days 00:02:38
2        0 days 00:02:38
3        0 days 00:02:38
4        0 days 00:02:38

I need format

0        00:02:38
1        00:02:38
2        00:02:38
3        00:02:38
4        00:02:38
Anthony
  • 13
  • 2
  • `((df['End time']) - (df['Start Solicitud']))`.datetime.strftime("%H:%M:%S") – inspectorG4dget Feb 03 '21 at 19:32
  • Please check . https://stackoverflow.com/questions/38895336/python-subtract-two-different-times-in-the-format-hhmmss-hhmmss I think this will help you – Arkadeep Feb 03 '21 at 19:36
  • Does this answer your question? [Python, subtract two different times in the format (HH:MM:SS - HH:MM:SS)](https://stackoverflow.com/questions/38895336/python-subtract-two-different-times-in-the-format-hhmmss-hhmmss) – noah Feb 03 '21 at 19:39
  • docs: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior – noah Feb 03 '21 at 19:40

0 Answers0