I am attempting to convert a list of strings to datetime.
Here is an example of the data I'm dealing with:
x = ['59:55:00', '59:55:00', '59:58:00', '1:00:02', '1:00:05', '1:01:26']
For example, the list is supposed to reflect 59 minutes, 58 seconds to 1 hour, 0 minutes and 5 seconds.
I understand this is a wacky format, but I'm playing with the hand I've been dealt. I'm not sure how to handle the data once I get into values that are greater than 59 minutes.
I tried using:
from datetime import datetime
for i in x:
datetime_object = datetime.strptime(i, '%M:%S:%f')
print(datetime_object)
My results are:
1900-01-01 00:59:55
1900-01-01 00:59:55
1900-01-01 00:59:58
1900-01-01 00:01:00.020000
1900-01-01 00:01:00.050000
1900-01-01 00:01:01.260000
I would like to keep my output to minutes and seconds.
For example 1:01:26
would be 00:61:26
So my desired output would look something like:
1900-01-01 00:59:55
1900-01-01 00:59:55
1900-01-01 00:59:58
1900-01-01 00:60:02
1900-01-01 00:60:02
1900-01-01 00:61:26
Any help or guidance is greatly appreciated!