अंतर्निहित डेटा के आकार का टपल वापस करने के लिए, 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,)