পান্ডাসে অর্ডার্ড CategoricalIndex-এর 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
catIndex = pd.CategoricalIndex(
["p", "q", "r", "s", "p", "q", "r", "s"],
ordered=True,
categories=["p", "q", "r", "s"]
)
print("Categorical Index...\n", catIndex)
print("\nDisplaying Categories from CategoricalIndex...\n", catIndex.categories)
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
নোট: ordered=True না হলে max() কল করলে TypeError হবে।