কম্পিউটার

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


প্রদত্ত DateOffset অবজেক্টে ন্যানোসেকেন্ডের সংখ্যা ফেরত দিতে, পান্ডাসে offset.nanos সম্পত্তি ব্যবহার করুন।

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

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

পান্ডাস-

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

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

ব্যবহার করে দিন বৃদ্ধি করছি
offset = to_offset("5D")

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

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

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

-এ ন্যানোসেকেন্ড ফেরত দিন
print("\nThe number of nanoseconds in the DateOffset object..\n", offset.nanos)

উদাহরণ

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

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

# Set the timestamp object in Pandas
timestamp = pd.Timestamp('2021-08-30 03:08:02.000045')

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

# Create the DateOffset
# We are incrementing the days here using the "D" frequency
offset = to_offset("5D")

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

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

# return the nanoseconds in the given DateOffset object
print("\nThe number of nanoseconds in the DateOffset object..\n", offset.nanos)

আউটপুট

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

Timestamp...
 2021-08-30 03:08:02.000045

DateOffset...
 <5 * Days>

Updated Timestamp...
 2021-09-04 03:08:02.000045

The number of nanoseconds in the DateOffset object..
 432000000000000

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

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

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

  4. Python Pandas - Timedelta অবজেক্ট থেকে ন্যানোসেকেন্ড ফেরত দিন