Period অবজেক্ট থেকে বছর বের করতে period.year প্রপার্টি ব্যবহার করুন।
প্রয়োজনীয় লাইব্রেরি ইম্পোর্ট করুন
import pandas as pd
দুটি Period অবজেক্ট তৈরি করুন
pandas.Period একটি সময়ের পরিধি উপস্থাপন করে।
period1 = pd.Period("2020-09-23")
period2 = pd.Period(freq="D", year=2021, month=4, day=16, hour=2, minute=35)
Period অবজেক্টগুলো প্রদর্শন করুন
print("Period1...\n", period1)
print("Period2...\n", period2)
দুটি Period অবজেক্ট থেকে বছর বের করুন
res1 = period1.year
res2 = period2.year
সম্পূর্ণ উদাহরণ
import pandas as pd
# দুটি Period অবজেক্ট তৈরি করুন
period1 = pd.Period("2020-09-23")
period2 = pd.Period(freq="D", year=2021, month=4, day=16, hour=2, minute=35)
# Period অবজেক্টগুলো প্রদর্শন করুন
print("Period1...\n", period1)
print("Period2...\n", period2)
# দুটি Period অবজেক্ট থেকে বছর বের করুন
res1 = period1.year
res2 = period2.year
# বছরের মান প্রদর্শন করুন
print("\nDisplay the Year from the 1st Period object ...\n", res1)
print("\nDisplay the Year from the 2nd Period object...\n", res2)
আউটপুট
Period1... 2020-09-23 Period2... 2021-04-16 Display the Year from the 1st Period object ... 2020 Display the Year from the 2nd Period object... 2021