2021年1月22日星期五

How to convert a column of strings in the form hh:mm to a time format

enter image description here

I am trying to read the column total_time and sum up the times where the user is the same meaning name 1 = 03:30 + 04:00 and so on, I am trying to use panda and I have manage to get the data separated but when I try take the total_time as this is an object I can not just sum it up, so I have tried to change the format of this object to a datetime object but I haven't been able to do it

format_time="%H:%M"    user1 = df.loc[df['user']== "name 1"]    user1['hora']=datetime.strptime((user1['total_time']),format_time)  

I have tried this and it gives me an error

AttributeError: module 'datetime' has no attribute 'strptime'  
https://stackoverflow.com/questions/65853678/how-to-convert-a-column-of-strings-in-the-form-hhmm-to-a-time-format January 23, 2021 at 06:38AM

没有评论:

发表评论