কম্পিউটার

Python Pandas - সূচকের ডুপ্লিকেট মান আছে কিনা তা পরীক্ষা করুন


ইনডেক্সের ডুপ্লিকেট মান আছে কিনা তা পরীক্ষা করতে, 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

  1. পাইথন - পান্ডাস সূচকে শুধুমাত্র পূর্ণসংখ্যা রয়েছে কিনা তা পরীক্ষা করুন

  2. Python - পান্ডাস সূচক একটি ভাসমান প্রকার কিনা তা পরীক্ষা করুন

  3. পাইথন - পান্ডাস সূচকে সুনির্দিষ্ট ডেটা আছে কিনা তা পরীক্ষা করুন

  4. পাইথন - পান্ডাস সূচকে শুধুমাত্র বুলিয়ান রয়েছে কিনা তা পরীক্ষা করুন