timedelta

How to convert objects or string to time format when the input string/object is malformed that is %H does not exist for all rows

别说谁变了你拦得住时间么 提交于 2020-05-31 04:58:10
问题 A similar question has been asked before but has received no responses I have looked through a number of forums for a solution. The other questions involve a year but mine does not - it is simply H:M:S I web scraped this data which returned Time - 36:42 38:34 1:38:32 1:41:18 Data samples here: Source data 1 and Source data 2 I need this time in minutes like so 36.70 38.57 98.53 101.30 To do this I tried this: time_mins = [] for i in time_list: h, m, s = i.split(':') math = (int(h) * 3600 +

How can I format time columns value from mm:ss to hh:mm:ss in python? e.g., 21:34 to 00:21:34

风流意气都作罢 提交于 2020-05-30 11:26:32
问题 In time column, there are values like: Time ======== 59:47 59:52 59:53 59:55 1:00:01 1:00:03 1:00:12 Now, I need to reshape the values like hh:mm:ss I have tried something like this: time_list = df7['Time'].tolist() for i in time_list: print(datetime.strptime(i,'%H:%M:%S')) ValueError: time data ' 36:21' does not match format '%H:%M:%S' 回答1: If you can normalise your values to always be of the form mm:ss or hh:mm:ss , with no additional components to them, then it's as simple as doing

How can I format time columns value from mm:ss to hh:mm:ss in python? e.g., 21:34 to 00:21:34

99封情书 提交于 2020-05-30 11:25:40
问题 In time column, there are values like: Time ======== 59:47 59:52 59:53 59:55 1:00:01 1:00:03 1:00:12 Now, I need to reshape the values like hh:mm:ss I have tried something like this: time_list = df7['Time'].tolist() for i in time_list: print(datetime.strptime(i,'%H:%M:%S')) ValueError: time data ' 36:21' does not match format '%H:%M:%S' 回答1: If you can normalise your values to always be of the form mm:ss or hh:mm:ss , with no additional components to them, then it's as simple as doing