কম্পিউটার

Python Pandas - প্রথম ঘটনা ব্যতীত ডুপ্লিকেট সূচক মান নির্দেশ করে


প্রথম ঘটনা ব্যতীত ডুপ্লিকেট সূচক মান নির্দেশ করতে, 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]

  1. Python Pandas - সূচকে অনন্য মান ফেরত দিন

  2. Python Pandas - মাস্কের সাথে সেট করা মানগুলির একটি নতুন সূচক ফেরত দিন

  3. Python Pandas - সূচক দ্বারা নির্বাচিত মানগুলির একটি নতুন সূচক ফেরত দিন

  4. Python Pandas - সূচী মান প্রতিস্থাপন করুন যেখানে শর্তটি মিথ্যা