BusinessDay 오프셋을 생성하려면 Pandas에서 pd.tseries.offsets.BusinessDay() 메서드를 사용하세요. 먼저 필요한 라이브러리를 가져옵니다 -
import datetime import pandas as pd
BusinessDay 오프셋을 만듭니다. BusinessDay는 DateOffset 하위 클래스입니다 -
bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(days = 7, hours = 7, minutes = 7))
영업일 오프셋 표시 -
print("BusinessDay Offset...\n",bdOffset)
Pandas에서 타임스탬프 개체 설정 -
timestamp = pd.Timestamp('2021-1-1 01:55:02.000045')
업데이트된 타임스탬프 표시 -
print("\nUpdated Timestamp...\n",timestamp + bdOffset)
예시
다음은 코드입니다 -
import datetime import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-1-1 01:55:02.000045') # Display the Timestamp print("Timestamp...\n",timestamp) # Create the BusinessDay Offset # BusinessDay is the DateOffset subclass bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(days = 7, hours = 7, minutes = 7)) # Display the BusinessDay Offset print("BusinessDay Offset...\n",bdOffset) # Display the Updated Timestamp print("\nUpdated Timestamp...\n",timestamp + bdOffset)
출력
이것은 다음 코드를 생성합니다 -
Timestamp... 2021-01-01 01:55:02.000045 BusinessDay Offset... <BusinessDay: offset=datetime.timedelta(days=7, seconds=25620)> Updated Timestamp... 2021-01-11 09:02:02.000045