সূচীগুলি খুঁজে পেতে যেখানে প্যান্ডাস সূচকে শৃঙ্খলা বজায় রাখতে অ্যারে হিসাবে পাস করা মানগুলি সন্নিবেশ করা উচিত, index.searchsorted() ব্যবহার করুন পদ্ধতি।
প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -
import pandas as pd
পান্ডাস সূচক তৈরি করা হচ্ছে -
index = pd.Index([10, 20, 30, 40, 50])
পান্ডাস সূচক প্রদর্শন করুন -
print("Pandas Index...\n",index) অনুসন্ধান বাছাই করা - একটি অ্যারের মত সন্নিবেশ করার জন্য মানগুলি সেট করুন এবং এই মানগুলি যেখানে স্থাপন করা উচিত তা সঠিক সূচকের অবস্থানগুলি পান −
print("\nThe exact positions where the values should be placed?...\n",index.searchsorted([35, 60])) উদাহরণ
নিম্নলিখিত কোড -
import pandas as pd
# Creating Pandas index
index = pd.Index([10, 20, 30, 40, 50])
# 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)
# searchsorted
# set the values to insert like an array and get the exact index positions
# where these values should be placed
print("\nThe exact positions where the values should be placed?...\n",index.searchsorted([35, 60])) আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেPandas Index... Int64Index([10, 20, 30, 40, 50], dtype='int64') Number of elements in the index... 5 The exact positions where the values should be placed?... [3 5]