BusinessHour ऑफ़सेट ऑब्जेक्ट पर लागू नियम कोड (rule code) प्राप्त करें
Pandas में BusinessHour.rule_code प्रॉपर्टी का उपयोग करके ऑफ़सेट पर लागू आवृत्ति का नियम कोड प्राप्त किया जा सकता है।
आवश्यक लाइब्रेरी आयात करें
import pandas as pd
टाइमस्टैम्प ऑब्जेक्ट सेट करें
timestamp = pd.Timestamp('2021-1-1 01:55:30')
BusinessHour ऑफ़सेट बनाएँ
bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end="18:00")
अपडेटेड टाइमस्टैम्प प्रदर्शित करें
print("\nUpdated Timestamp...\n", timestamp + bhOffset)
नियम कोड प्राप्त करें
print("\nThe rule code of the BusinessHour object..\n", bhOffset.rule_code)
पूर्ण उदाहरण
import pandas as pd
# टाइमस्टैम्प सेट करें
timestamp = pd.Timestamp('2021-1-1 01:55:30')
print("Timestamp...\n", timestamp)
# BusinessHour ऑफ़सेट बनाएँ
bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end="18:00")
# ऑफ़सेट प्रदर्शित करें
print("\nBusinessHour Offset...\n", bhOffset)
# अपडेटेड टाइमस्टैम्प
print("\nUpdated Timestamp...\n", timestamp + bhOffset)
# नियम कोड प्राप्त करें
print("\nThe rule code of the BusinessHour object..\n", bhOffset.rule_code)
आउटपुट
Timestamp...
2021-01-01 01:55:30
BusinessHour Offset...
<BusinessHour: BH=09:30-18:00>
Updated Timestamp...
2021-01-01 10:30:00
The rule code of the BusinessHour object.. BH
व्याख्या
rule_codeआवृत्ति का संक्षिप्त कोड लौटाता है- BusinessHour के लिए यह
'BH'लौटाता है - यह कोड आवृत्ति स्ट्रिंग्स और ऑफ़सेट पहचान में उपयोग होता है