কম্পিউটার

Python Pandas - PeriodIndex অবজেক্ট থেকে পিরিয়ডের মিনিট পান


PeriodIndex বস্তু থেকে সময়কালের মিনিট পেতে, PeriodIndex.minute ব্যবহার করুন সম্পত্তি।

প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -

import pandas as pd

একটি PeriodIndex অবজেক্ট তৈরি করুন। PeriodIndex হল একটি অপরিবর্তনীয় ndarray যার অর্ডিনাল মান ধারণ করে যা নির্দিষ্ট সময়ের মধ্যে নিয়মিত পিরিয়ড নির্দেশ করে −

periodIndex = pd.PeriodIndex(['2021-09-25 07:30:35', '2019-10-30 04:15:45',
'2021-07-15 02:55:15', '2022-06-25 09:40:55'], freq="T")

ডিসপ্লে PeriodIndex অবজেক্ট −

print("PeriodIndex...\n", periodIndex)

PeriodIndex অবজেক্ট -

থেকে মিনিট প্রদর্শন করুন
print("\nThe minute from the PeriodIndex object...\n", periodIndex.minute)

উদাহরণ

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

import pandas as pd

# Create a PeriodIndex object
# PeriodIndex is an immutable ndarray holding ordinal values indicating regular periods in time
# We have set the frequency using the "freq" parameter
periodIndex = pd.PeriodIndex(['2021-09-25 07:30:35', '2019-10-30 04:15:45',
'2021-07-15 02:55:15', '2022-06-25 09:40:55'], freq="T")

# Display PeriodIndex object
print("PeriodIndex...\n", periodIndex)

# Display PeriodIndex frequency
print("\nPeriodIndex frequency object...\n", periodIndex.freq)

# Display PeriodIndex frequency as string
print("\nPeriodIndex frequency object as a string...\n", periodIndex.freqstr)

# Display minute from the PeriodIndex object
print("\nThe minute from the PeriodIndex object...\n", periodIndex.minute)

আউটপুট

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

PeriodIndex...
PeriodIndex(['2021-09-25 07:30', '2019-10-30 04:15', '2021-07-15 02:55', '2022-06-25 09:40'],
dtype='period[T]')

PeriodIndex frequency object...
<Minute>

PeriodIndex frequency object as a string...
T

The minute from the PeriodIndex object...
Int64Index([30, 15, 55, 40], dtype='int64')

  1. Python Pandas - প্রদত্ত পিরিয়ড অবজেক্টের ফ্রিকোয়েন্সি পান

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

  3. Python Pandas - Timedelta অবজেক্ট থেকে মোট সেকেন্ড সময় পান

  4. Python - পান্ডাসে টাইমস্ট্যাম্প অবজেক্ট থেকে সপ্তাহের দিন পান