কম্পিউটার

Python Pandas - বছরের উপাদানের মাস পান


পিরিয়ডের বছরের উপাদানের মাস পেতে, period.month ব্যবহার করুন সম্পত্তি প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -

import pandas as pd

পান্ডা. পিরিয়ড সময়কালের প্রতিনিধিত্ব করে। দুটি পিরিয়ড অবজেক্ট তৈরি করা

period1 = pd.Period("2020-09-23 05:55:30")
period2 = pd.Period(freq="M", year = 2021, month = 8, day = 16, hour = 2, minute = 35)

পিরিয়ড অবজেক্টগুলি প্রদর্শন করুন

print("Period1...\n", period1)
print("Period2...\n", period2)

দুটি পিরিয়ড অবজেক্ট থেকে বছরের মাস পান

res1 = period1.month
res2 = period2.month

উদাহরণ

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

import pandas as pd

# The pandas.Period represents a period of time
# creating two Period objects
period1 = pd.Period("2020-09-23 05:55:30")
period2 = pd.Period(freq="M", year = 2021, month = 8, day = 16, hour = 2, minute = 35)

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

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

# Return the Month from the two Period objects
print("\nMonth from the 1st Period object ...\n", res1)
print("\nMonth from the 2nd Period object...\n", res2)

আউটপুট

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

Period1...
2020-09-23 05:55:30
Period2...
2021-08

Month from the 1st Period object ...
9

Month from the 2nd Period object...
8

  1. Python Pandas - যে মাসের মধ্যে পিরিয়ড পড়ে তার মোট দিনের সংখ্যা পান

  2. Python Pandas - পিরিয়ড অবজেক্ট থেকে বছরের দিন পান

  3. Python Pandas - পিরিয়ড যে সপ্তাহে আছে সেই সপ্তাহের দিন পান

  4. Python Pandas - মাসের যে দিনটি একটি পিরিয়ড পড়ে সেই দিনটি পান৷