কম্পিউটার

Python Pandas - প্রদত্ত PeriodIndex অবজেক্টে প্রতিটি উপাদানের জন্য পিরিয়ডের শেষ সময় প্রদর্শন করুন


প্রদত্ত PeriodIndex অবজেক্টের প্রতিটি উপাদানের জন্য পিরিয়ডের শেষ সময় প্রদর্শন করতে, PeriodIndex.end_time ব্যবহার করুন সম্পত্তি।

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

import pandas as pd

একটি PeriodIndex অবজেক্ট তৈরি করুন। PeriodIndex হল একটি অপরিবর্তনীয় ndarray যার অর্ডিনাল মান রয়েছে যা নির্দিষ্ট সময়ের মধ্যে নিয়মিত পিরিয়ড নির্দেশ করে। আমরা "freq" প্যারামিটার −

ব্যবহার করে ফ্রিকোয়েন্সি সেট করেছি
periodIndex = pd.PeriodIndex(['2018-07-25', '2019-10-30', '2020-11-20',
'2021-09-15', '2022-03-12', '2023-06-18'], freq="D")

ডিসপ্লে PeriodIndex অবজেক্ট −

print("PeriodIndex...\n", periodIndex)

শেষ সময় প্রদর্শন করুন -

print("\nEnd Time...\n", periodIndex.end_time)

উদাহরণ

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

import pandas as pd

# Create a PeriodIndex object
# PeriodIndex is an immutable ndarray holding ordinal values indicating regular periods in time
# We have set the frequency using the "freq" parameter
periodIndex = pd.PeriodIndex(['2018-07-25', '2019-10-30', '2020-11-20',
'2021-09-15', '2022-03-12', '2023-06-18'], freq="D")

# Display PeriodIndex object
print("PeriodIndex...\n", periodIndex)

# Display PeriodIndex frequency
print("\nPeriodIndex frequency...\n", periodIndex.freq)

# Display the end time
print("\nEnd Time...\n", periodIndex.end_time)

আউটপুট

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

PeriodIndex...
PeriodIndex(['2018-07-25', '2019-10-30', '2020-11-20', '2021-09-15', '2022-03-12', '2023-06-18'],
dtype='period[D]')

PeriodIndex frequency...
<Day>

End Time...
DatetimeIndex(['2018-07-25 23:59:59.999999999',
               '2019-10-30 23:59:59.999999999',
               '2020-11-20 23:59:59.999999999',
               '2021-09-15 23:59:59.999999999',
               '2022-03-12 23:59:59.999999999',
               '2023-06-18 23:59:59.999999999'],
               dtype='datetime64[ns]', freq=None)

  1. Python Pandas - TimeDeltaIndex থেকে প্রতিটি উপাদানের জন্য ন্যানোসেকেন্ডের সংখ্যা বের করুন

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

  3. Python Pandas - প্রদত্ত পিরিয়ড অবজেক্টের শেষ সময় খুঁজুন

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