Python Forum
Adding times in ISO format? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Adding times in ISO format? (/thread-13786.html)



Adding times in ISO format? - amca01 - Oct-31-2018

I have a list of times in ISO format: HH:MM:SS representing the durations of various activities. I'd like to add them all. However, much as I've searched the documentation of datetime, I can't find how to do it. I can convert them to timedeltas, and add those to get a result in seconds - but surely there's a more direct way? I can also write my own program, but I would have thought that something so basic as adding times would be built in.

Anyway, any help or advice would be welcome! Thanks.

I've discovered, since I'm working with Pandas, that pandas.Timedelta does exactly what I want!


RE: Adding times in ISO format? - Larz60+ - Oct-31-2018

FYI - If at some point you need it,
There's a good write-up on datetime here: https://pymotw.com/3/datetime/