0
월 ~ 금, 오전 7 시부 터 오후 5 시까 지 근무하는 시간이 있습니다. 2 열의 시작 날짜와 종료 날짜에서 근무일과 시간의 no를 계산하고 싶습니다.Python pandas는 pandas 데이터 프레임의 두 날짜 필드에서 영업일 및 영업 시간을 계산합니다.
에서이
Sno start date end date
1 4/6/2017 23:18 6/6/2017 21:23
2 4/6/2017 16:40 5/6/2017 2:52
3 5/6/2017 0:10 5/6/2017 4:10
4 5/6/2017 0:37 5/6/2017 7:16
5 5/6/2017 2:02 5/6/2017 10:48
Sno start date end date Bus Days Bus hours
1 4/6/2017 23:18 6/6/2017 21:23 1 10:00
2 4/6/2017 16:40 5/6/2017 2:52 0 0:20
3 5/6/2017 0:10 5/6/2017 4:10 0 0
4 5/6/2017 0:37 5/6/2017 7:16 0 0:16
5 5/6/2017 2:02 5/6/2017 10:48 0 3:48
에 나는 다음 시도했지만있어 몇 가지 오류
from BusinessHours import BusinessHours as bh
df['bhours'] = (bh(df['start date'] , df['end date'] , worktiming=[7 , 17] , weekends=[6,7]).gethours()).astype('timedelta64[D]')
AttributeError: 'Series' object has no attribute 'days'
그럼 난
df['bhours'] = len(pd.bdate_range(df['start date'] , df['end date'])).astype('timedelta64[D]')
TypeError: Cannot convert input [0 2017-04-06 18:52:00
df['bdays'] = (np.busday_count(df['start date'] , df['end date'])).astype('timedelta64[D]')
TypeError: Iterator operand 0 dtype could not be cast from dtype('<M8[ns]') to dtype('<M8[D]') according to the rule 'safe'
이 문제를 해결하는 데 도움 주시기 바랍니다 다른 해결책을 시도했다.
시작일로 작성되고 종료일로 해결 된 svs 코드를 읽으십시오. –