如何找到多个事件的两个时间之间的持续时间?
我的任务是找出为总线充电的时间,而充电类型= 1时,这意味着充电器已插入。我如何找到此持续时间?另外,我需要找出充电频率,有什么方法也可以做到吗?
这是当前的代码:
#Duration loop
foundEnd = False
for i in range(len(dfDur01Mar22)):
#only display bus 'SG3079S'
if dfDur01Mar22.iloc[i,1] == 'SG3079S':
#print 'end' when first '0' appears
if not foundEnd and dfDur01Mar22.iloc[i,2] == 0:
print('end')
foundEnd = True
#if charging type is 1
elif dfDur01Mar22.iloc[i,2] == 1:
print(dfDur01Mar22.iloc[i,0],dfDur01Mar22.iloc[i,1],dfDur01Mar22.iloc[i,2])
foundEnd = False
这是从中的输出: 在此处输入图像描述
My task is to find out how long the bus is charged for, and when charging type = 1, it means that the charger is plugged in. How do i find the duration from this? Also i need to find out the charging frequency, is there a way i can do that too?
Here is the code currently:
#Duration loop
foundEnd = False
for i in range(len(dfDur01Mar22)):
#only display bus 'SG3079S'
if dfDur01Mar22.iloc[i,1] == 'SG3079S':
#print 'end' when first '0' appears
if not foundEnd and dfDur01Mar22.iloc[i,2] == 0:
print('end')
foundEnd = True
#if charging type is 1
elif dfDur01Mar22.iloc[i,2] == 1:
print(dfDur01Mar22.iloc[i,0],dfDur01Mar22.iloc[i,1],dfDur01Mar22.iloc[i,2])
foundEnd = False
and here is the output from it :
enter image description here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用DateTime模块来找出2个事件之间的时间:
You can use the datetime module to figure out the amount of time between 2 events: