ใช้ property CustomBusinessHour.normalize เพื่อตรวจสอบว่า offset ถูก normalize (ตั้งเวลาเป็น 00:00:00) หรือไม่
ขั้นตอน
- import pandas as pd
- สร้าง timestamp และ CustomBusinessHour offset พร้อม normalize=True
- เข้าถึง
cbhOffset.normalize
ตัวอย่างโค้ด
import pandas as pd
timestamp = pd.Timestamp('2021-10-25 08:35:10')
cbhOffset = pd.tseries.offsets.CustomBusinessHour(n=3, weekmask='Mon Tue Wed Fri Sat', normalize=True)
print("Timestamp...\n", timestamp)
print("\nCustomBusinessHour Offset...\n", cbhOffset)
print("\nUpdated Timestamp...\n", timestamp + cbhOffset)
print("\nFrequency applied on the given CustomBusinessHour Offset object...\n", cbhOffset.freqstr)
print("\nThe name of the frequency on the CustomBusinessHour object..\n", cbhOffset.name)
print("\nThe CustomBusinessHour Offset is normalized ?\n", cbhOffset.normalize)
ผลลัพธ์
Timestamp... 2021-10-25 08:35:10 CustomBusinessHour Offset... <3 * CustomBusinessHours: CBH=09:00-17:00> Updated Timestamp... 2021-10-25 00:00:00 Frequency applied on the given CustomBusinessHour Offset object... 3CBH The name of the frequency on the CustomBusinessHour object.. CBH The CustomBusinessHour Offset is normalized ? True