প্রথম ঘটনা ব্যতীত ডুপ্লিকেট সূচক মান নির্দেশ করতে, index.duplicated() ব্যবহার করুন। কিপ ব্যবহার করুন প্রথম। মান সহ প্যারামিটার
প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -
import pandas as pd
কিছু সদৃশ-
দিয়ে সূচক তৈরি করা হচ্ছেindex = pd.Index(['Car','Bike','Airplane','Ship','Airplane'])
সূচক প্রদর্শন করুন -
print("Pandas Index with duplicates...\n",index) ডুপ্লিকেট সূচক মানকে সত্য হিসাবে নির্দেশ করুন, প্রথম ঘটনাটি ছাড়া। "প্রথম" -
হিসাবে "কিপ" প্যারামিটার সেট করুনprint("\nIndicating duplicate values except the first occurrence...\n", index.duplicated(keep='first')) উদাহরণ
নিম্নলিখিত কোড -
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 duplicate index values as True, except the first occurrence
# Set the "keep" parameter as "first"
print("\nIndicating duplicate values except the first occurrence...\n", index.duplicated(keep='first')) আউটপুট
এটি নিম্নলিখিত কোড তৈরি করবে -
Pandas Index with duplicates... Index(['Car', 'Bike', 'Airplane', 'Ship', 'Airplane'], dtype='object') The dtype object... object Get the dimensions... 1 Indicating duplicate values except the first occurrence... [False False False False True]