কম্পিউটার

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


অর্ডার করা ক্যাটেগরিক্যাল ইনডেক্স থেকে ন্যূনতম মান পেতে, 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
থেকে ন্যূনতম মান
  1. পাইথন - পান্ডাস সূচকের সর্বনিম্ন মান ফেরত দিন

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

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

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