Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert datetime.timedelta to minutes

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Take the total_seconds and divide by 60.

>>> import datetime
>>> td = datetime.timedelta(seconds=90)
>>> td.total_seconds() / 60
1.5
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading