কম্পিউটার

Python Pandas - অর্ডারকৃত ক্যাটেগরিক্যাল ইনডেক্স থেকে সর্বোচ্চ মান পান


অর্ডার করা ক্যাটেগরিক্যাল ইনডেক্স থেকে সর্বোচ্চ মান পেতে, পান্ডাসে catIndex.max() পদ্ধতি ব্যবহার করুন।

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

import pandas as pd

"বিভাগ" পরামিতি ব্যবহার করে শ্রেণীগত জন্য বিভাগ সেট করুন। "অর্ডার করা" পরামিতি −

ব্যবহার করে শ্রেণীবদ্ধকে ক্রমানুসারে বিবেচনা করুন
catIndex = pd.CategoricalIndex(
   ["p", "q", "r", "s","p", "q", "r", "s"], ordered=True, categories=["p", "q", "r", "s"]
)

শ্রেণীগত সূচক প্রদর্শন করুন -

print("Categorical Index...\n",catIndex)

সর্বাধিক মান −

পান
print("\nMaximum value from CategoricalIndex...\n",catIndex.max())

উদাহরণ

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

import pandas as pd

# CategoricalIndex can only take on a limited, and usually fixed, number of possible values.
# Set the categories for the categorical using the "categories" parameter
# Treat the categorical as ordered using the "ordered" parameter
catIndex = pd.CategoricalIndex(
   ["p", "q", "r", "s","p", "q", "r", "s"], ordered=True, categories=["p", "q", "r", "s"]
)

# Display the Categorical Index
print("Categorical Index...\n",catIndex)

# Get the categories
print("\nDisplaying Categories from CategoricalIndex...\n",catIndex.categories)

# Get the max value
print("\nMaximum value from CategoricalIndex...\n",catIndex.max())

আউটপুট

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
Categorical Index...
CategoricalIndex(['p', 'q', 'r', 's', 'p', 'q', 'r', 's'], categories=['p', 'q', 'r', 's'], ordered=True, dtype='category')

Displaying Categories from CategoricalIndex...
Index(['p', 'q', 'r', 's'], dtype='object')

Maximum value from CategoricalIndex...
S

  1. Python - পান্ডাস সূচকের সর্বোচ্চ মান ফেরত দিন

  2. Python Pandas - Timedelta অবজেক্টের সর্বোচ্চ মান ফেরত দিন

  3. Python Pandas - TimeDelta থেকে দিনের সংখ্যা পান

  4. Python Tkinter এ একটি চেকবক্স থেকে কিভাবে ইনপুট পেতে হয়?