কম্পিউটার

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


প্রদত্ত DateOffset অবজেক্টে প্রয়োগ করা নিয়ম কোড ফেরত দিতে, পান্ডাসে offset.rule_code ব্যবহার করুন। প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -

from pandas.tseries.frequencies import to_offset
import pandas as pd

পান্ডাস-

-এ টাইমস্ট্যাম্প অবজেক্ট সেট করুন
timestamp = pd.Timestamp('2021-09-26 03:25:02.000045')

ডেটঅফসেট তৈরি করুন। আমরা এখানে "M" ফ্রিকোয়েন্সি −

ব্যবহার করে মাস বৃদ্ধি করছি
offset = to_offset("3M")

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

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

প্রদত্ত DateOffset অবজেক্ট -

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

উদাহরণ

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

from pandas.tseries.frequencies import to_offset
import pandas as pd

# Set the timestamp object in Pandas
timestamp = pd.Timestamp('2021-09-26 03:25:02.000045')

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

# Create the DateOffset
# We are incrementing the months here using the "M" frequency
offset = to_offset("3M")

# Display the DateOffset
print("\nDateOffset...\n",offset)

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

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

আউটপুট

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

Timestamp...
 2021-09-26 03:25:02.000045

DateOffset...
 <3 * MonthEnds>

Updated Timestamp...
 2021-11-30 03:25:02.000045

The rule code of the DateOffset object..
 M

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

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

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

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