0
月曜日午前7時から午後5時まで勤務時間があります。私は2列の開始日と終了日から営業日数と時間数を計算したい。Python pandasは、pandasデータフレームの2つの日付フィールドで営業日と営業時間を計算します
からは
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のコードをお読みください。 –