অর্ডার করা ক্যাটেগরিক্যাল ইনডেক্স থেকে ন্যূনতম মান পেতে, catIndex.min() ব্যবহার করুন পান্ডাসে পদ্ধতি। প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -
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("\nMinimum value from CategoricalIndex...\n",catIndex.min()) উদাহরণ
নিম্নলিখিত কোড -
import pandas as pd
# CategoricalIndex is the Index based on an underlying Categorical
# 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("\nDisplayingCategories from CategoricalIndex...\n",catIndex.categories)
# Get the min value
print("\nMinimum value from CategoricalIndex...\n",catIndex.min()) আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেCategorical Index... CategoricalIndex(['p', 'q', 'r', 's', 'p', 'q', 'r', 's'], categories=['p', 'q', 'r', 's'], ordered=True, dtype='category') DisplayingCategories from CategoricalIndex... Index(['p', 'q', 'r', 's'], dtype='object') Minimum value from CategoricalIndex... Pথেকে ন্যূনতম মান