কম্পিউটার টিউটোরিয়াল

পাইথন প্যান্ডাস - Period অবজেক্ট থেকে মাসের দিন বের করুন

একটি Period অবজেক্ট কোন মাসের কোন দিনে পড়ে তা জানতে period.day প্রোপার্টি ব্যবহার করুন।

প্রয়োজনীয় লাইব্রেরি ইমপোর্ট করুন

import pandas as pd

দুটি Period অবজেক্ট তৈরি করুন

period1 = pd.Period("2021-09-18")
period2 = pd.Period(freq='D', year=2021, month=9, day=22, hour=4, minute=55)

মাসের দিন বের করুন

res1 = period1.day
res2 = period2.day

সম্পূর্ণ উদাহরণ

import pandas as pd

# The pandas.Period represents a period of time
# creating two Period objects
period1 = pd.Period("2021-09-18")
period2 = pd.Period(freq='D', year=2021, month=9, day=22, hour=4, minute=55)

# display the Period objects
print("Period1...\n", period1)
print("Period2...\n", period2)

# get the day of the month from two Period objects
res1 = period1.day
res2 = period2.day

# Return the day of the month from the two Period objects
print("\nDay of the month from the 1st Period object ...\n", res1)
print("\nDay of the month from the 2nd Period object...\n", res2)

আউটপুট

Period1... 2021-09-18
Period2... 2021-09-22
Day of the month from the 1st Period object ... 18
Day of the month from the 2nd Period object... 22

ব্যাখ্যা: period.day সরাসরি মাসের তারিখ (১-৩১) রিটার্ন করে। এটি dayofyear (বছরের দিন) বা dayofweek (সপ্তাহের দিন) থেকে আলাদা।

  1. Python Pandas - Period-এ মাসের মোট দিন সংখ্যা জানুন

  2. পাইথন প্যান্ডাস - Period অবজেক্ট থেকে বছরের দিন বের করুন

  3. পাইথন প্যান্ডাস - Period অবজেক্টের সপ্তাহের দিন বের করুন

  4. পাইথনে মাসের শেষ দিন পাওয়ার পদ্ধতি