BusinessHour ऑफ़सेट पर लागू वृद्धि (increments) की संख्या प्राप्त करें
Pandas में BusinessHour.n प्रॉपर्टी का उपयोग करके ऑफ़सेट ऑब्जेक्ट पर लागू वृद्धि की संख्या प्राप्त की जा सकती है।
आवश्यक लाइब्रेरी आयात करें
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", n=8)
अपडेटेड टाइमस्टैम्प प्रदर्शित करें
print("\nUpdated Timestamp...\n", timestamp + bhOffset)
वृद्धि की संख्या प्राप्त करें
print("\nThe count of increments on the BusinessHour object..\n", bhOffset.n)
पूर्ण उदाहरण
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", n=8)
# ऑफ़सेट प्रदर्शित करें
print("\nBusinessHour Offset...\n", bhOffset)
# अपडेटेड टाइमस्टैम्प
print("\nUpdated Timestamp...\n", timestamp + bhOffset)
# वृद्धि की संख्या प्राप्त करें
print("\nThe count of increments on the BusinessHour object..\n", bhOffset.n)
आउटपुट
Timestamp...
2021-01-01 01:55:30
BusinessHour Offset...
<8 * BusinessHours: BH=09:30-18:00>
Updated Timestamp...
2021-01-01 17:30:00
The count of increments on the BusinessHour object.. 8
व्याख्या
nप्रॉपर्टी ऑफ़सेट निर्माण के दौरान पास किए गए मान को लौटाती है- यह दर्शाता है कि कितने व्यावसायिक घंटे जोड़े जाएँगे
- उदाहरण में
n=8सेट किया गया है, इसलिए आउटपुट 8 है