ใช้ property CustomBusinessDay.rule_code เพื่อคืนรหัสกติกา (rule code) ของความถี่ที่ใช้กับ CustomBusinessDay offset
ขั้นตอน
- import pandas as pd
- สร้าง timestamp และ CustomBusinessDay offset
- เข้าถึง
cbdOffset.rule_code
ตัวอย่างโค้ด
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')
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 rule code of the CustomBusinessDay object..\n", cbdOffset.rule_code)
ผลลัพธ์
Timestamp... 2021-10-22 03:10:35 CustomBusinessDay Offset... <2 * CustomBusinessDays> Updated Timestamp... 2021-10-26 03:10:35 Frequency applied on the given CustomBusinessDay Offset object... 2C The rule code of the CustomBusinessDay object.. C