जांचने के लिए कि पैंडास इंडेक्स ऑब्जेक्ट dtype का है या नहीं, index.is_object() मेथड का उपयोग करें। सबसे पहले आवश्यक लाइब्रेरी इम्पोर्ट करें:
import pandas as pd
पैंडास इंडेक्स बनाएं:
index = pd.Index(["Electronics", 6, 10.5, "Accessories", 25.6, 30])
पैंडास इंडेक्स प्रदर्शित करें:
print("Pandas Index...\n",index)
जांचें कि इंडेक्स वैल्यूज में ऑब्जेक्ट dtype है या नहीं:
print("\nIs the Index of object dtype?\n", index.is_object())
उदाहरण
निम्न कोड है:
import pandas as pd
# पैंडास इंडेक्स बनाना
index = pd.Index(["Electronics", 6, 10.5, "Accessories", 25.6, 30])
# पैंडास इंडेक्स प्रदर्शित करना
print("Pandas Index...\n",index)
# इंडेक्स में एलिमेंट्स की संख्या लौटाएं
print("\nNumber of elements in the index...\n",index.size)
# डेटा का dtype लौटाएं
print("\nThe dtype object...\n",index.dtype)
# जांचें कि इंडेक्स वैल्यूज में ऑब्जेक्ट dtype है या नहीं
print("\nIs the Index of object dtype?\n", index.is_object())
आउटपुट
यह निम्न आउटपुट देगा:
Pandas Index... Index(['Electronics', 6, 10.5, 'Accessories', 25.6, 30], dtype='object') Number of elements in the index... 6 The dtype object... object Is the Index of object dtype? True