Home > other >  Convert datetime.timedelta to minutes
Convert datetime.timedelta to minutes

Time:03-03

I used Python pandas to create an output list:

[Timedelta('0 days 11:10:39.836405529'),
 Timedelta('0 days 00:32:24.919831223')]

However, my javascript chart cannot phrase it as valid input data. I want to convert this list to minutes, so my output will be something like this:

[274.65, 32.4]

Is that possible to do that?

CodePudding user response:

Take the total_seconds and divide by 60.

>>> import datetime
>>> td = datetime.timedelta(seconds=90)
>>> td.total_seconds() / 60
1.5
  • Related