ใช้ property CustomBusinessHour.start เพื่อดึงเวลาเริ่มต้นของชั่วโมงทำการแบบกำหนดเองในรูปแบบ 24 ชั่วโมง
ขั้นตอน
- import pandas as pd
- สร้าง timestamp และ CustomBusinessHour offset พร้อมระบุ start, end, n
- เข้าถึง
cbhOffset.start
ตัวอย่างโค้ด
import pandas as pd
timestamp = pd.Timestamp('2021-11-14 05:20:30')
cbhOffset = pd.tseries.offsets.CustomBusinessHour(start="09:30", end="18:00", n=8)
print("Timestamp...\n", timestamp)
print("\nCustomBusinessHour Offset...\n", cbhOffset)
print("\nUpdated Timestamp...\n", timestamp + cbhOffset)
print("\nThe start time of the custom business hour...\n", cbhOffset.start)
ผลลัพธ์
Timestamp... 2021-11-14 05:20:30 CustomBusinessHour Offset... <8 * CustomBusinessHours: CBH=09:30-18:00> Updated Timestamp... 2021-11-15 17:30:00 The start time of the custom business hour... (datetime.time(9, 30),)