I have a .csv file that includes 2 columns, begin_time & end_time which contain records in this format: 2013-02-12 16:21:48 . They start from 2013 till 2017. My goal is to convert all of them to only 16:21:48 part, so I'll be able to map all of the datasets into a [00:00:00 - 23:59:59] range to monitor them through 24 hours of the day to check abnormal events. So I want to remove the yy:mm:dd part of the record, and only keep the hh:mm:ss part.
These are the datasets of smart home events and I'm trying to discover the activities and the abnormal changes among them.
I have tried datetime.strftime(time_records, format="%H:%M:%S") and it returns str, but when I try to convert the str to pandas.timestamps, it brings back the yy:mm:dd
I expect the 2013-02-12 16:21:48 to be 16:21:48 in timestamp or datetime format, so I'll be able to convert them to UNIX timestamp format.
Thanks in advance
from datetime import datetime
a='2013-02-12 16:21:48'
c=datetime.strptime(a,'%Y-%m-%d %H:%M:%S').time()
print(c)
output
16:21:48
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.