코드를 첨부 하겠지만 기본적으로 특정 항목의 사례를 선택하기위한 시작 시간/종료 시간과 함께 CSV 파일을 가져옵니다. 모든 케이스는 ID 번호로 식별되는 "장바구니"로 이동합니다. 나는 모든 경우를 선택하는 총 시간을 찾고 싶다. 시간 형식은 hh : mm : ss이며 초기에는 datetime 모듈을 사용하고 있었지만 설명서를 이해할 수 없었기 때문에 모든 시간을 초로 변환하고 각 경우에 대해 end/start를 뺀 다음, 그 기간을 총 시간에 더한다. 결국 총 시간을 시간으로 변환합니다. 이미 총 사례를 골라 내고 총 시간을 시간으로 나눠서 시간당 사례를 얻었습니다. 이 논리가 정확한가요? 나는 매우 낮고 매우 낮은 숫자를 가지고있다 : 7.99 건/시간, 이는 내 타이밍/지속 시간 코드가 잘못되었다고 믿게한다. (이미 수량이 정확하다는 것을 확인했다.)여러 중복 항목으로 총 시간을 유지하는 방법은 무엇입니까?
#instantiate totalTime to zero
totalTime = 0
#every line/row in file; assume already opened above
for line in lines:
#if there is a different case to pick, find the start time
if taskId != entryList[0]: #this is so it doesnt duplicate times
timestart = entryList[7]
colonStartIndex = timestart.find(":")
hourstart = int(timestart[0:colonStartIndex])
minutestart = int(timestart[colonStartIndex+1:colonStartIndex+3])
colonStartIndex2 = timestart.find(":", colonStartIndex+1)
secondstart = int(timestart[colonStartIndex2 +1:colonStartIndex2 +3])
start = hourstart*3600 + minutestart*60 + secondstart
#start = datetime(year=1, month=1, day=1,hour=hourstart,minute=minutestart,second=secondstart)
#start = datetime.time(start)
timeend = entryList[9]
colonEndIndex = timeend.find(":")
hourend = int(timeend[0:colonEndIndex])
minuteend = int(timeend[colonEndIndex+1:colonEndIndex+3])
colonEndIndex2 = timeend.find(":", colonEndIndex+1)
secondend = int(timeend[colonEndIndex2+1:colonEndIndex2+3])
end = hourend*3600 + minuteend*60 + secondend
#end = datetime(year=1,month=1,day=1,hour=hourend,minute=minuteend,second=secondend)
#end = datetime.time(end)
#duration = datetime.combine(date.today(), end) - datetime.combine(date.today(), start)
duration = end - start
if duration >= 0:
duration = duration
elif duration < 0:
duration = -1*duration
totalTime = totalTime + duration
taskId = entryList[0] #first entry in csv file of each line is cartID
totalTime = totalTime/3600
print(totalTime)
print(quantityCount)
avgNumCases = quantityCount/totalTime
print(avgNumCases)
도움을 주셔서 감사합니다. 또한, datetime 항목을 포함하여 주석 처리 했으므로이를 기반으로 솔루션을 제안 할 수 있다면 공개적으로 생각할 수 있습니다 :) 나는 그것을 이해하려고 시간을 보냈기 때문에 좌절감을 느꼈지만,
당신의 시작점이duration = end - start
if duration >= 0:
duration = duration
elif duration < 0:
duration = -1*duration
경우 IT 및 문서 w 슈퍼 익숙하지 m은