Pandas의 BusinessHour.next_bday 속성을 사용하여 다음 영업일로 이동합니다. 먼저 필요한 라이브러리를 가져옵니다 -
import datetime import pandas as pd
BusinessHour 오프셋을 생성합니다. BusinessHour는 DateOffset 하위 클래스입니다 -
bhOffset = pd.tseries.offsets.BusinessHour(offset = datetime.timedelta(days = 3, hours = 3))
BusinessHour 오프셋 표시 -
print("\nBusinessHour Offset...\n",bhOffset)
Pandas에서 타임스탬프 개체 설정 -
timestamp = pd.Timestamp('2021-9-30 06:50:20')
다음 영업일 표시 -
print("\nThe next business day...\n",timestamp + bhOffset.next_bday)
예시
다음은 코드입니다 -
import datetime import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-9-30 06:50:20') # Display the Timestamp print("Timestamp...\n",timestamp) # Create the BusinessHour Offset # BusinessHour is the DateOffset subclass bhOffset = pd.tseries.offsets.BusinessHour(offset = datetime.timedelta(days = 3, hours = 3)) # Display the BusinessHour Offset print("\nBusinessHour Offset...\n",bhOffset) # Display the next business day print("\nThe next business day...\n",timestamp + bhOffset.next_bday)
출력
이것은 다음 코드를 생성합니다 -
Timestamp... 2021-09-30 06:50:20 BusinessHour Offset... <BusinessHour: offset=datetime.timedelta(days=3, seconds=10800): BH=09:00-17:00> The next business day... 2021-10-01 06:50:20