अंतर्निहित डेटा के dtype ऑब्जेक्ट को वापस करने के लिए, index.dtype . का उपयोग करें पंडों में संपत्ति।
सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
अनुक्रमणिका बनाना -
index = pd.Index(['Car','Bike', 'Shop','Car','Airplace', 'Truck'])
सूचकांक प्रदर्शित करें -
print("Pandas Index...\n",index) डेटा का प्रकार लौटाएं -
print("\nThe dtype object...\n",index.dtype)
उदाहरण
निम्नलिखित कोड है -
import pandas as pd
# Creating the index
index = pd.Index(['Car','Bike', 'Shop','Car','Airplace', 'Truck'])
# Display the index
print("Pandas Index...\n",index)
# Return an array representing the data in the Index
print("\nArray...\n",index.values)
# Return the dtype of the data
print("\nThe dtype object...\n",index.dtype)
# 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', 'Shop', 'Car', 'Airplace', 'Truck'], dtype='object') Array... ['Car' 'Bike' 'Shop' 'Car' 'Airplace' 'Truck'] The dtype object... object A tuple of the shape of underlying data... (6,)