PeriodIndex বস্তু থেকে সময়কালের সেকেন্ড পেতে, PeriodIndex.second ব্যবহার করুন সম্পত্তি।
প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -
import pandas as pd
একটি PeriodIndex অবজেক্ট তৈরি করুন। PeriodIndex হল একটি অপরিবর্তনীয় ndarray যার অর্ডিনাল মান ধারণ করে যা নির্দিষ্ট সময়ের মধ্যে নিয়মিত পিরিয়ড নির্দেশ করে −
periodIndex = pd.PeriodIndex(['2021-09-25 07:30:35', '2019-10-30 04:15:45', '2021-07-15 02:55:15', '2022-06-25 09:40:55'], freq="S")
ডিসপ্লে PeriodIndex অবজেক্ট −
print("PeriodIndex...\n", periodIndex)
PeriodIndex অবজেক্ট -
থেকে সেকেন্ড প্রদর্শন করুনprint("\nThe seconds from the PeriodIndex object...\n", periodIndex.second) উদাহরণ
নিম্নলিখিত কোড -
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(['2021-09-25 07:30:35', '2019-10-30 04:15:45',
'2021-07-15 02:55:15', '2022-06-25 09:40:55'], freq="S")
# Display PeriodIndex object
print("PeriodIndex...\n", periodIndex)
# Display PeriodIndex frequency
print("\nPeriodIndex frequency object...\n", periodIndex.freq)
# Display PeriodIndex frequency as string
print("\nPeriodIndex frequency object as a string...\n", periodIndex.freqstr)
# Display seconds from the PeriodIndex object
print("\nThe seconds from the PeriodIndex object...\n", periodIndex.second) আউটপুট
এটি নিম্নলিখিত কোড তৈরি করবে -
PeriodIndex... PeriodIndex(['2021-09-25 07:30:35', '2019-10-30 04:15:45', '2021-07-15 02:55:15', '2022-06-25 09:40:55'], dtype='period[S]') PeriodIndex frequency object... <Second> PeriodIndex frequency object as a string... S The seconds from the PeriodIndex object... Int64Index([35, 45, 15, 55], dtype='int64')