BusinessDay Offset이 정규화되었는지 확인하려면 Pandas에서 BusinessDay.normalize 속성을 사용하세요.
먼저 필요한 라이브러리를 가져옵니다 -
import datetime import pandas as pd
Pandas에서 타임스탬프 개체 설정 -
timestamp = pd.Timestamp('2021-10-30 01:55:02.000045')
BusinessDay 오프셋을 만듭니다. BusinessDay는 DateOffset 하위 클래스입니다. "normalize" 매개변수를 사용하여 BusinessDay를 정규화했습니다 -
bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(hours = 8, minutes = 10), normalize=True)
업데이트된 타임스탬프 표시 -
print("\nUpdated Timestamp...\n",timestamp + bdOffset)
BusinessDay Offset이 정규화되었는지 확인하십시오 -
print("\nThe BusinessDay Offset is normalized..\n", bdOffset.normalize)
예시
다음은 코드입니다 -
import datetime import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-10-30 01:55:02.000045') # Display the Timestamp print("Timestamp...\n",timestamp) # Create the BusinessDay Offset # BusinessDay is the DateOffset subclass # We have normalized the BusinessDay using the "normalize" parameter bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(hours = 8, minutes = 10), normalize=True) # Display the BusinessDay Offset print("\nBusinessDay Offset...\n",bdOffset) # Display the Updated Timestamp print("\nUpdated Timestamp...\n",timestamp + bdOffset) # return the frequency applied on the given BusinessDay object as a string print("\nFrequency on the given BusinessDay Offset...\n",bdOffset.freqstr) # return the name of the frequency applied on the given BusinessDay object print("\nThe name of the frequency on the BusinessDay object..\n", bdOffset.name) # check whether the BusinessDay Offset is normalized or not print("\nThe BusinessDay Offset is normalized..\n", bdOffset.normalize)
출력
이것은 다음 코드를 생성합니다 -
Timestamp... 2021-10-30 01:55:02.000045 BusinessDay Offset... <BusinessDay: offset=datetime.timedelta(seconds=29400)> Updated Timestamp... 2021-11-01 00:00:00 Frequency on the given BusinessDay Offset... B+8H10Min The name of the frequency on the BusinessDay object.. B The BusinessDay Offset is normalized.. True