কম্পিউটার

Python Pandas CategoricalIndex - এই ক্যাটাগরিকালের বিভাগগুলি পান


এই ক্যাটাগরিকালের বিভাগগুলি পেতে, বিভাগগুলি ব্যবহার করুন৷ CategoricalIndex এর সম্পত্তি পান্ডায় প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -

import pandas as pd

CategoricalIndex শুধুমাত্র একটি সীমিত, এবং সাধারণত স্থির, সম্ভাব্য মানগুলির সংখ্যা গ্রহণ করতে পারে (বিভাগ। "বিভাগগুলি" প্যারামিটার ব্যবহার করে শ্রেণীবিভাগের জন্য বিভাগগুলি সেট করুন। "অর্ডার করা" প্যারামিটার ব্যবহার করে শ্রেণীবদ্ধকে ক্রম অনুসারে বিবেচনা করুন −

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)

উদাহরণ

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

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)

আউটপুট

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

তৈরি করবে
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')

  1. Python Pandas CategoricalIndex - এই ক্যাটাগরিকালের বিভাগ কোডগুলি পান

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

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

  4. Python Pandas - পিরিয়ডের দ্বিতীয় উপাদান পান