我试图找出此数据帧中的开始时间和最后时间(分钟)之间的差异:
StartTime LastTime
1 00:02:05 00:02:05
2 00:07:05 00:07:05
3 00:12:06 00:12:06
4 00:17:06 00:17:06
当我对数据运行以下代码时
from datetime import datetime
date_format = "%H:%M.%S"
# You could also pass datetime.time object in this part and convert it to string.
time_start = str(UDP_interval['StartTime'])
time_end = str(UDP_interval['LastTime'])
# Then get the difference here.
diff = datetime.strptime(time_end, date_format) -
datetime.strptime(time_start, date_format)
# Get the time in hours i.e. 9.60, 8.5
result = diff.seconds / 3600;
我得到这个错误:
dtype: object' does not match format '%H:%M:%S'
你也许应该使用:
相关问题 更多 >
编程相关推荐