ใช้ property CustomBusinessDay.normalize เพื่อตรวจสอบว่า offset ถูก normalize (ตั้งเวลาเป็น 00:00:00) หรือไม่
ขั้นตอน
- import pandas as pd
- สร้าง timestamp และ CustomBusinessDay offset พร้อม normalize=True
- เข้าถึง
cbdOffset.normalize
ตัวอย่างโค้ด
import pandas as pd
timestamp = pd.Timestamp('2021-10-22 03:10:35')
cbdOffset = pd.tseries.offsets.CustomBusinessDay(n=2, weekmask='Mon Tue Wed Fri', normalize=True)
print("Timestamp...\n", timestamp)
print("\nCustomBusinessDay Offset...\n", cbdOffset)
print("\nUpdated Timestamp...\n", timestamp + cbdOffset)
print("\nFrequency applied on the given CustomBusinessDay Offset object...\n", cbdOffset.freqstr)
print("\nThe CustomBusinessDay Offset is normalized ?\n", cbdOffset.normalize)
ผลลัพธ์
Timestamp... 2021-10-22 03:10:35 CustomBusinessDay Offset... <2 * CustomBusinessDays> Updated Timestamp... 2021-10-26 00:00:00 Frequency applied on the given CustomBusinessDay Offset object... 2C The CustomBusinessDay Offset is normalized ? True