কম্পিউটার

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


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

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 name of the frequency on the DateOffset object..\n",
offset.name)

উদাহরণ

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

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 name of the frequency applied on the given DateOffset object
print("\nThe name of the frequency on the DateOffset object..\n", offset.name)

আউটপুট

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

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

DateOffset...
 <3 * MonthEnds>

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

The name of the frequency on the DateOffset object..
 M

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

  2. Python Pandas - দৈনিক ফ্রিকোয়েন্সি সহ একটি টাইমস্ট্যাম্প হিসাবে পিরিয়ড অবজেক্টটি ফেরত দিন

  3. Python Pandas - পিরিয়ড অবজেক্টটিকে মিনিটে ফ্রিকোয়েন্সি সহ টাইমস্ট্যাম্প হিসাবে ফিরিয়ে দিন

  4. Python Pandas - মাসিক ফ্রিকোয়েন্সি সহ একটি টাইমস্ট্যাম্প হিসাবে পিরিয়ড অবজেক্টটি ফেরত দিন