BusinessHour ऑफ़सेट ऑब्जेक्ट से कस्टम व्यावसायिक घंटे का प्रारंभ समय प्राप्त करें
Pandas में BusinessHour.start प्रॉपर्टी का उपयोग करके कस्टम व्यावसायिक घंटे का प्रारंभ समय 24-घंटे फॉर्मेट में प्राप्त किया जा सकता है।
आवश्यक लाइब्रेरी आयात करें
import pandas as pd
टाइमस्टैम्प ऑब्जेक्ट सेट करें
timestamp = pd.Timestamp('2021-9-30 06:50:20')
कस्टम BusinessHour ऑफ़सेट बनाएँ
bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end="18:00", n=8)
कस्टम व्यावसायिक घंटे का प्रारंभ समय प्राप्त करें
print("\nThe start time of the custom business hour...\n", bhOffset.start)
पूर्ण उदाहरण
import pandas as pd
# टाइमस्टैम्प सेट करें
timestamp = pd.Timestamp('2021-9-30 06:50:20')
print("Timestamp...\n", timestamp)
# कस्टम BusinessHour ऑफ़सेट बनाएँ
bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end="18:00", n=8)
# ऑफ़सेट प्रदर्शित करें
print("\nBusinessHour Offset...\n", bhOffset)
# अपडेटेड टाइमस्टैम्प
print("\nUpdated Timestamp...\n", timestamp + bhOffset)
# प्रारंभ समय प्राप्त करें
print("\nThe start time of the custom business hour...\n", bhOffset.start)
आउटपुट
Timestamp...
2021-09-30 06:50:20
BusinessHour Offset...
<8 * BusinessHours: BH=09:30-18:00>
Updated Timestamp...
2021-09-30 17:30:00
The start time of the custom business hour...
(datetime.time(9, 30),)
मुख्य बिंदु
startप्रॉपर्टीdatetime.timeऑब्जेक्ट वाला टपल लौटाती है- यहाँ प्रारंभ समय 09:30 (सुबह 9:30 बजे) है
- यह कस्टम व्यावसायिक घंटे परिभाषित करते समय उपयोगी है