ইনডেক্সের ডুপ্লিকেট মান আছে কিনা তা পরীক্ষা করতে, index.has_duplicates ব্যবহার করুন পান্ডাসে সম্পত্তি।
প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -
import pandas as pd
সূচক তৈরি করা হচ্ছে -
index = pd.Index(['Car','Bike','Truck','Car','Airplane'])
সূচক প্রদর্শন করুন -
print("Pandas Index...\n",index) সূচীতে ডুপ্লিকেট মান আছে কিনা তা পরীক্ষা করুন −
print("\nIs the Pandas index having duplicate values?\n",index.has_duplicates)
উদাহরণ
নিম্নলিখিত কোড -
import pandas as pd
# Creating the index
index = pd.Index(['Car','Bike','Truck','Car','Airplane'])
# Display the index
print("Pandas Index...\n",index)
# Return an array representing the data in the Index
print("\nArray...\n",index.values)
# Check if the index is having duplicate values
print("\nIs the Pandas index having duplicate values?\n",index.has_duplicates) আউটপুট
এটি নিম্নলিখিত কোড তৈরি করবে -
Pandas Index... Index(['Car', 'Bike', 'Truck', 'Car', 'Airplane'], dtype='object') Array... ['Car' 'Bike' 'Truck' 'Car' 'Airplane'] Is the Pandas index having duplicate values? True