প্যান্ডাস সিরিজের প্রতিটি এলিমেন্ট ভিন্নভাবে রিপিট করতে, index.repeat() মেথড ব্যবহার করুন।
প্রয়োজনীয় লাইব্রেরি আমদানি
import pandas as pd
প্যান্ডাস ইন্ডেক্স তৈরি
index = pd.Index(['Car','Bike','Airplane', 'Ship'], name='Transport')
প্যান্ডাস ইন্ডেক্স প্রদর্শন
print("প্যান্ডাস ইন্ডেক্স...\n", index)
ইন্ডেক্সের প্রতিটি এলিমেন্ট ভিন্নভাবে রিপিট করা
print("\nপ্রতিটি ইন্ডেক্স এলিমেন্ট ভিন্নভাবে রিপিট করার ফলাফল...\n", index.repeat([2,3,5,7]))
সম্পূর্ণ উদাহরণ
import pandas as pd
# প্যান্ডাস ইন্ডেক্স তৈরি
index = pd.Index(['Car','Bike','Airplane', 'Ship'], name='Transport')
# প্যান্ডাস ইন্ডেক্স প্রদর্শন
print("প্যান্ডাস ইন্ডেক্স...\n", index)
# ইন্ডেক্সে এলিমেন্টের সংখ্যা ফেরত দাও
print("\nইন্ডেক্সে এলিমেন্টের সংখ্যা...\n", index.size)
# ডেটার dtype ফেরত দাও
print("\nDtype অবজেক্ট...\n", index.dtype)
# ইন্ডেক্সের প্রতিটি এলিমেন্ট ভিন্নভাবে রিপিট করা
print("\nপ্রতিটি ইন্ডেক্স এলিমেন্ট ভিন্নভাবে রিপিট করার ফলাফল...\n", index.repeat([2,3,5,7]))
আউটপুট
প্যান্ডাস ইন্ডেক্স... Index(['Car', 'Bike', 'Airplane', 'Ship'], dtype='object', name='Transport') ইন্ডেক্সে এলিমেন্টের সংখ্যা... 4 Dtype অবজেক্ট... object প্রতিটি ইন্ডেক্স এলিমেন্ট ভিন্নভাবে রিপিট করার ফলাফল... Index(['Car', 'Car', 'Bike', 'Bike', 'Bike', 'Airplane', 'Airplane', 'Airplane', 'Airplane', 'Airplane', 'Ship', 'Ship', 'Ship', 'Ship', 'Ship', 'Ship', 'Ship'], dtype='object', name='Transport')