Period অবজেক্ট থেকে বছরের সপ্তাহ বের করতে period.weekofyear প্রপার্টি ব্যবহার করুন।
প্রয়োজনীয় লাইব্রেরি ইম্পোর্ট করুন
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.weekofyear
res2 = period2.weekofyear
সম্পূর্ণ উদাহরণ
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)
# বছরের সপ্তাহ বের করুন
res1 = period1.weekofyear
res2 = period2.weekofyear
# বছরের সপ্তাহ প্রদর্শন করুন
print("\nWeek of the year from the 1st Period object ...\n", res1)
print("\nWeek of the year from the 2nd Period object...\n", res2)
আউটপুট
Period1... 2020-09-23 Period2... 2021-04-16 Week of the year from the 1st Period object ... 39 Week of the year from the 2nd Period object... 15