কম্পিউটার

Python Pandas - প্রদত্ত BusinessDay অবজেক্টে প্রয়োগ করা নিয়ম কোড ফেরত দিন


প্রদত্ত BusinessDay অবজেক্টে প্রয়োগ করা নিয়ম কোড ফেরত দিতে, পান্ডাসে BusinessDay.rule_code প্রপার্টি ব্যবহার করুন।

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

import datetime
import pandas as pd

পান্ডাস-

-এ টাইমস্ট্যাম্প অবজেক্ট সেট করুন
timestamp = pd.Timestamp('2021-10-30 01:55:02.000045')

বিজনেস ডে অফসেট তৈরি করুন। ব্যবসা দিবস হল তারিখ অফসেট সাবক্লাস −

bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(hours = 8, minutes = 10))

আপডেট করা টাইমস্ট্যাম্প −

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

প্রদত্ত বিজনেসডে অফসেট -

-এ প্রয়োগ করা ফ্রিকোয়েন্সির নিয়ম কোডটি ফেরত দিন
print("\nThe rule code of the BusinessDay object..\n", bdOffset.rule_code)

উদাহরণ

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

import datetime
import pandas as pd

# Set the timestamp object in Pandas
timestamp = pd.Timestamp('2021-10-30 01:55:02.000045')

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

# Create the BusinessDay Offset
# BusinessDay is the DateOffset subclass
bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(hours = 8, minutes = 10))

# Display the BusinessDay Offset
print("\nBusinessDay Offset...\n",bdOffset)

# Display the Updated Timestamp
print("\nUpdated Timestamp...\n",timestamp + bdOffset)

# return the frequency applied on the given BusinessDay object as a string
print("\nFrequency on the given BusinessDay Offset...\n",bdOffset.freqstr)

# return the rule code of the frequency applied on the given BusinessDay Offset
print("\nThe rule code of the BusinessDay object..\n", bdOffset.rule_code)

আউটপুট

এটি নিম্নলিখিত কোড তৈরি করবে -

Timestamp...
 2021-10-30 01:55:02.000045

BusinessDay Offset...
 <BusinessDay: offset=datetime.timedelta(seconds=29400)>

Updated Timestamp...
 2021-11-01 10:05:02.000045

Frequency on the given BusinessDay Offset...
 B+8H10Min

The rule code of the BusinessDay object..
 B

  1. Python Pandas - অফসেট অবজেক্টে প্রয়োগ করা ফ্রিকোয়েন্সিটির নাম ফেরত দিন

  2. Python Pandas - প্রদত্ত তারিখ অফসেট অবজেক্টে প্রয়োগ করা ফ্রিকোয়েন্সি ফেরত দিন

  3. Python Pandas - প্রদত্ত ডেটঅফসেট অবজেক্টে ন্যানোসেকেন্ডের সংখ্যা ফেরত দিন

  4. Python Pandas - প্রদত্ত তারিখ অফসেট অবজেক্টে স্ট্রিং হিসাবে রিটার্ন ফ্রিকোয়েন্সি প্রয়োগ করা হয়েছে