পাইথন প্যান্ডাসে DateTimeIndex.is_quarter_start প্রোপার্টি ব্যবহার করে DateTimeIndex-এ الموجودة তারিখটি কোয়ার্টারের প্রথম দিন কিনা তা যাচাই করা যায়। এটি একটি বুলিয়ান অ্যারে রিটার্ন করে যেখানে প্রতিটি উপাদান নির্দেশ করে সংশ্লিষ্ট তারিখ কোয়ার্টারের প্রথম দিন কিনা।
প্রয়োজনীয় লাইব্রেরি ইম্পোর্ট করুন
import pandas as pd
DatetimeIndex তৈরি করুন
৬টি পিরিয়ড এবং ৩০ দিনের ফ্রিকোয়েন্সি (freq='30D') সহ একটি DatetimeIndex তৈরি করুন। টাইমজোন أستراليا/এডিলেড।
datetimeindex = pd.date_range('2021-10-1 02:30:50', periods=6, tz='Australia/Adelaide', freq='30D')
DateTimeIndex প্রদর্শন করুন
print("DateTimeIndex...\n", datetimeindex)
কোয়ার্টারের প্রথম দিন কিনা তা চেক করুন
print("\nCheck whether the date in DateTimeIndex is the first day of the quarter...\n", datetimeindex.is_quarter_start)
সম্পূর্ণ উদাহরণ
import pandas as pd
# ৬টি পিরিয়ড এবং ৩০ দিনের ফ্রিকোয়েন্সি সহ DatetimeIndex
# টাইমজোন: Australia/Adelaide
datetimeindex = pd.date_range('2021-10-1 02:30:50', periods=6, tz='Australia/Adelaide', freq='30D')
# DateTimeIndex প্রদর্শন
print("DateTimeIndex...\n", datetimeindex)
# DateTimeIndex ফ্রিকোয়েন্সি প্রদর্শন
print("DateTimeIndex frequency...\n", datetimeindex.freq)
# কোয়ার্টারের প্রথম দিন কিনা চেক করুন
# বছরের কোয়ার্টারها:
# কোয়ার্টার ১ = ১ জানুয়ারি থেকে ৩১ মার্চ
# কোয়ার্টার ২ = ১ এপ্রিল থেকে ৩০ জুন
# কোয়ার্টার ৩ = ১ জুলাই থেকে ৩০ সেপ্টেম্বর
# কোয়ার্টার ৪ = ১ অক্টোবর থেকে ৩১ ডিসেম্বর
print("\nCheck whether the date in DateTimeIndex is the first day of the quarter...\n", datetimeindex.is_quarter_start)
আউটপুট
DateTimeIndex... DatetimeIndex(['2021-10-01 02:30:50+09:30', '2021-10-31 02:30:50+10:30', '2021-11-30 02:30:50+10:30', '2021-12-30 02:30:50+10:30', '2022-01-29 02:30:50+10:30', '2022-02-28 02:30:50+10:30'], dtype='datetime64[ns, Australia/Adelaide]', freq='30D') DateTimeIndex frequency... <30 * Days> Check whether the date in DateTimeIndex is the first day of the quarter... [True False False False False False]
ব্যাখ্যা: প্রথম তারিখ (২০২১-১০-০১) কোয়ার্টার ৪-এর প্রথম দিন হওয়ায় True দেখাচ্ছে, বাকিগুলো False।