কম্পিউটার টিউটোরিয়াল

পাইথন প্যান্ডাস - সমস্ত ডুপ্লিকেট ইনডেক্স মানকে True হিসেবে চিহ্নিত করুন

ইনডেক্সে কোনো মান একাধিকবার আসলে সেগুলো সব True হিসেবে চিহ্নিত করতে index.duplicated(keep=False) ব্যবহার করুন। keep=False মানে কোনো ensimmäisen বা শেষ~Occurrence কে False ধরা হবে না; সব ডুপ্লিকেট True হবে।

প্রয়োজনীয় লাইব্রেরি ইমপোর্ট করুন

import pandas as pd

ডুপ্লিকেট সহ ইনডেক্স তৈরি করুন

index = pd.Index(['Car','Bike','Airplane','Ship','Airplane'])

ইনডেক্স প্রদর্শন করুন

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

সমস্ত ডুপ্লিকেট True হিসেবে চিহ্নিত করুন

print("\nIndicating all duplicate index values True...\n", index.duplicated(keep=False))

সম্পূর্ণ উদাহরণ

import pandas as pd

# Creating the index with some duplicates
index = pd.Index(['Car','Bike','Airplane','Ship','Airplane'])

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

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

# get the dimensions of the data
print("\nGet the dimensions...\n", index.ndim)

# Indicate all duplicate index values as True
# Set the "keep" parameter as "False"
print("\nIndicating all duplicate index values True...\n", index.duplicated(keep=False))

আউটপুট

Pandas Index with duplicates... Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane'], dtype='object')
The dtype object... object
Get the dimensions... 1
Indicating all duplicate index values True... [False False True False True]

ব্যাখ্যা: 'Airplane' দুবার এসেছে (ইন্ডেক্স ২ এবং ৪), তাই দুটোই True। keep='first' (ডিফল্ট) দিলে প্রথমটো False, দ্বিতীয়টো True হতো। keep='last' দিলে প্রথমটো True, দ্বিতীয়টো False হতো।

  1. পাইথন - পান্ডাসে সকল নাল মানযুক্ত কলাম সরানো

  2. পাইথন - পান্ডাস ডেটাফ্রেমে অসীম মানগুলোর জন্য True প্রদর্শন

  3. Python-এ Pandas DataFrame থেকে ডুপ্লিকেট ভ্যালু রিমুভ করার পদ্ধতি

  4. Python Pandas-এ দুটি ইন্ডেক্স ভ্যালুর মধ্যে DataFrame সারি সিলেক্ট করা