প্রদত্ত CustomBusinessDay অবজেক্টে প্রয়োগ করা নিয়ম কোড ফেরত দিতে, Pandas-এ CustomBusinessDay.rule_code প্রপার্টি ব্যবহার করুন।
প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -
import pandas as pd
পান্ডাস-
-এ টাইমস্ট্যাম্প অবজেক্ট সেট করুনtimestamp = pd.Timestamp('2021-10-22 03:10:35')
CustomBusinessDay অফসেট তৈরি করুন। CustomBusinessDay হল ডেটঅফসেট সাবক্লাস যা ছুটির দিনগুলি ব্যতীত কাস্টম ব্যবসার দিনগুলি উপস্থাপন করে −
cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri')
টাইমস্ট্যাম্পে অফসেট যোগ করুন এবং আপডেট করা টাইমস্ট্যাম্প −
প্রদর্শন করুনprint("\nUpdated Timestamp...\n",timestamp + cbdOffset)
প্রদত্ত কাস্টম বিজনেসডে অফসেটে প্রয়োগ করা ফ্রিকোয়েন্সির নিয়ম কোডটি ফেরত দিন −
print("\nThe rule code of the CustomBusinessDay object..\n", cbdOffset.rule_code) উদাহরণ
নিম্নলিখিত কোড -
import pandas as pd
# Set the timestamp object in Pandas
timestamp = pd.Timestamp('2021-10-22 03:10:35')
# Display the Timestamp
print("Timestamp...\n",timestamp)
# Create the CustomBusinessDay Offset
# CustomBusinessDay is the DateOffset subclass representing custom business days excluding holidays
# Weekmask of valid business days
cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri')
# Display the CustomBusinessDay Offset
print("\nCustomBusinessDay Offset...\n",cbdOffset)
# Add the offset to the Timestamp and display the Updated Timestamp
print("\nUpdated Timestamp...\n",timestamp + cbdOffset)
# Return frequency applied on the given CustomBusinessDay Offset object as a string
print("\nFrequency applied on the given CustomBusinessDay Offset object...\n",cbdOffset.freqstr)
# Return the rule code of the frequency applied on the given CustomBusinessDay Offset
print("\nThe rule code of the CustomBusinessDay object..\n", cbdOffset.rule_code) আউটপুট
এটি নিম্নলিখিত কোড তৈরি করবে -
Timestamp... 2021-10-22 03:10:35 CustomBusinessDay Offset... <2 * CustomBusinessDays> Updated Timestamp... 2021-10-26 03:10:35 Frequency applied on the given CustomBusinessDay Offset object... 2C The rule code of the CustomBusinessDay object.. C