例如: 我想找到车辆的偏差: 偏差定义:
驾驶超过4小时,且不间断至少1小时。1小时的休息时间可分为15分钟。任何少于15分钟的休息将不被视为休息。 运输=车辆正在运行 &;停止=中断
要计算偏差: 连续驾驶超过4小时的每小时将计为1次。例如,如果车辆连续行驶5小时2分钟,则计数为2(第5小时和第6小时的2分钟)
无法构建此逻辑
以下是玩具数据链接:
https://drive.google.com/file/d/1oWl6_k5KxTkztKAaYb6nO2PcI3gBs2RH/view?usp=sharing
我已经尝试过这一点:但我不知道该怎么做:
out['StartDateTime'] = pd.to_datetime(out['StartDate'].dt.date.astype(str)+ ' '+ out['StartTime'].astype(str))
out['EndDateTime'] = pd.to_datetime(out['EndDate'].dt.date.astype(str)+ ' '+ out['EndTime'].astype(str))
out['Duration'] = (out['EndDateTime'] - out['StartDateTime']).astype('timedelta64[m]')
itr = 0
run = 0
stop = 0
dfg = out.groupby(['companyid','Vehicle'])
df_newout = pd.DataFrame()
while itr in (enumerate(out)):
if run < 240 & stop < 60:
run = out[out['EventType'] == 'Transit']['Duration'].sum()
stop = out[out['EventType'] == 'Stop']['Duration'].sum()
run.append(itr)
stop.append(itr)
itr = itr+1
这是一个有点复杂的问题要解决。不管怎样,这是解决办法。看看这是不是你想要的。根据目前提供的数据,没有违规行为
您可以添加这两行,以了解有多少违反了规则
或者,您可以使用以下方法检查违规情况:
根据提供的数据,我没有发现任何违规行为。如果您手动计数并发现违规,请告诉我,以便修复代码中的逻辑
相关问题 更多 >
编程相关推荐