অন্তর্নিহিত ডেটার আকারের একটি টুপল ফেরত দিতে, index.shape ব্যবহার করুন পান্ডাসে সম্পত্তি।
প্রথমে, প্রয়োজনীয় লাইব্রেরিগুলি আমদানি করুন -
import pandas as pd
সূচক তৈরি করা হচ্ছে -
index = pd.Index(['Car','Bike','Truck','Car','Airplane'])
সূচক প্রদর্শন করুন -
print("Pandas Index...\n",index) অন্তর্নিহিত ডেটা −
এর আকারের একটি টিপল ফেরত দিনprint("\nA tuple of the shape of underlying data...\n",index.shape)
উদাহরণ
নিম্নলিখিত কোড -
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)
# Return a tuple of the shape of the underlying data
print("\nA tuple of the shape of underlying data...\n",index.shape) আউটপুট
এটি নিম্নলিখিত কোড তৈরি করবে -
Pandas Index... Index(['Car', 'Bike', 'Truck', 'Car', 'Airplane'], dtype='object') Array... ['Car' 'Bike' 'Truck' 'Car' 'Airplane'] A tuple of the shape of underlying data... (5,)