কম্পিউটার

Python Pandas - কাস্টম বিজনেস আওয়ার অফসেট অবজেক্ট থেকে 24 ঘন্টা ফরম্যাটে কাস্টম ব্যবসার সময় শুরুর সময় প্রদর্শন করুন


কাস্টম বিজনেস আওয়ার অফসেট অবজেক্ট থেকে 24 ঘন্টা ফরম্যাটে কাস্টম ব্যবসার সময়ের শুরুর সময় প্রদর্শন করতে, পান্ডাসে CustomBusinessHour.start প্রপার্টি ব্যবহার করুন৷

প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -

import pandas as pd

পান্ডাস-

-এ টাইমস্ট্যাম্প অবজেক্ট সেট করুন
timestamp = pd.Timestamp('2021-11-14 05:20:30')

কাস্টম বিজনেস আওয়ার অফসেট তৈরি করুন। এখানে, "শুরু" হল 24 ঘন্টা বিন্যাসে আপনার কাস্টম ব্যবসার সময়ের শুরুর সময়। "শেষ" হল আপনার কাস্টম ব্যবসায়িক সময়ের 24 ঘন্টা বিন্যাসে −

এর শেষ সময়
cbhOffset = pd.tseries.offsets.CustomBusinessHour(start="09:30", end = "18:00", n = 8)

টাইমস্ট্যাম্পে অফসেট যোগ করুন এবং আপডেট করা টাইমস্ট্যাম্প −

প্রদর্শন করুন
print("\nUpdated Timestamp...\n",timestamp + cbhOffset)

কাস্টম ব্যবসার সময় শুরু করার সময় প্রদর্শন করুন -

print("\nThe start time of the custom business hour...\n",cbhOffset.start)

উদাহরণ

নিম্নলিখিত কোড -

import pandas as pd

# Set the timestamp object in Pandas
timestamp = pd.Timestamp('2021-11-14 05:20:30')

# Display the Timestamp
print("Timestamp...\n",timestamp)

# Create the CustomBusinessHour Offset
# CustomBusinessHour is the DateOffset subclass
# Here, "start" is the start time of your custom business hour in 24h format.
# The "end" is the end time of your custom business hour in 24h format.
cbhOffset = pd.tseries.offsets.CustomBusinessHour(start="09:30", end = "18:00", n = 8)

# Display the CustomBusinessHour Offset
print("\nCustomBusinessHour Offset...\n",cbhOffset)

# Add the offset to the Timestamp and display the Updated Timestamp
print("\nUpdated Timestamp...\n",timestamp + cbhOffset)

# Display the start time of the custom business hour
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),)

  1. Python Pandas - প্রদত্ত পিরিয়ড অবজেক্টের জন্য শুরুর সময় খুঁজুন

  2. Python - পান্ডাসে টাইমস্ট্যাম্প অবজেক্ট থেকে সপ্তাহের দিন পান

  3. Python Pandas - UTC অফসেট সময় পান

  4. Python Pandas - টাইমস্ট্যাম্প অবজেক্ট থেকে বর্তমান তারিখ এবং সময় পান