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