কম্পিউটার

Python Pandas - পূর্ণসংখ্যা সূচকগুলি ফেরত দিন যা সূচীকে সাজাতে হবে


পূর্ণসংখ্যা সূচকগুলি ফেরত দিতে যা সূচী বাছাই করবে, index.argsort() ব্যবহার করুন পান্ডাসে পদ্ধতি। প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -

import pandas as pd

পান্ডাস সূচক তৈরি করা হচ্ছে -

index = pd.Index(['Electronics','Accessories','Decor', 'Books', 'Toys'], name ='Products')

পান্ডাস সূচক প্রদর্শন করুন -

print("Pandas Index...\n",index)

পূর্ণসংখ্যা সূচকগুলি ফেরত দিন যা সূচী বাছাই করবে −

res = index.argsort()

উদাহরণ

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

import pandas as pd

# Creating Pandas index
index = pd.Index(['Electronics','Accessories','Decor', 'Books', 'Toys'], name ='Products')

# Display the Pandas index
print("Pandas Index...\n",index)

# Return the number of elements in the Index
print("\nNumber of elements in the index...\n",index.size)

# Return the dtype of the data
print("\nThe dtype object...\n",index.dtype)

res = index.argsort()

# Return the integer indices that would sort the index
print("\nThe integer indices to sort the index...\n",res)

print("\nOrdered..\n",index[res])

আউটপুট

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

তৈরি করবে
Pandas Index...
Index(['Electronics', 'Accessories', 'Decor', 'Books', 'Toys'], dtype='object', name='Products')

Number of elements in the index...
5

The dtype object...
object

The integer indices to sort the index...
[1 3 2 0 4]

Ordered..
Index(['Accessories', 'Books', 'Decor', 'Electronics', 'Toys'], dtype='object', name='Products')

  1. Python Pandas - সূচক দ্বারা নির্বাচিত মানগুলির একটি নতুন সূচক ফেরত দিন

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

  3. পাইথন - পান্ডাস সূচকের সর্বনিম্ন মান ফেরত দিন

  4. Python Pandas - একটি সূচী হিসাবে IntervalArray-এ প্রতিটি ব্যবধানের মধ্যবিন্দু ফেরত দিন