ใช้ property CustomBusinessHour.name เพื่อคืนชื่อความถี่ (frequency name) ที่ใช้กับ CustomBusinessHour offset
ขั้นตอน
- import pandas as pd
- สร้าง timestamp และ CustomBusinessHour offset
- เข้าถึง
cbhOffset.name
ตัวอย่างโค้ด
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')
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)
ผลลัพธ์
Timestamp... 2021-10-25 08:35:10 CustomBusinessHour Offset... <3 * CustomBusinessHours: CBH=09:00-17:00> Updated Timestamp... 2021-10-25 12:00:00 Frequency applied on the given CustomBusinessHour Offset object... 3CBH The name of the frequency on the CustomBusinessHour object.. CBH