जांचने के लिए कि पैंडास इंडेक्स में केवल इंटीजर हैं या नहीं, पैंडास में index.is_integer() मेथड का उपयोग करें। सबसे पहले आवश्यक लाइब्रेरी इम्पोर्ट करें:
import pandas as pd
पैंडास इंडेक्स बनाएं:
index = pd.Index([5, 10, 25, 50, 75, 100, 125, 150])
पैंडास इंडेक्स प्रदर्शित करें:
print("Pandas Index...\n",index)
जांचें कि इंडेक्स वैल्यूज में केवल इंट्स हैं या नहीं:
print("\nIndex values only consists of integers?\n",index.is_integer())
उदाहरण
निम्न कोड है:
import pandas as pd
# पैंडास इंडेक्स बनाना
index = pd.Index([5, 10, 25, 50, 75, 100, 125, 150])
# पैंडास इंडेक्स प्रदर्शित करना
print("Pandas Index...\n",index)
# इंडेक्स में एलिमेंट्स की संख्या लौटाएं
print("\nNumber of elements in the index...\n",index.size)
# डेटा का dtype लौटाएं
print("\nThe dtype object...\n",index.dtype)
# जांचें कि इंडेक्स वैल्यूज में केवल इंट्स हैं या नहीं
print("\nIndex values only consists of integers?\n",index.is_integer())
आउटपुट
यह निम्न आउटपुट देगा:
Pandas Index... Int64Index([5, 10, 25, 50, 75, 100, 125, 150], dtype='int64') Number of elements in the index... 8 The dtype object... int64 Index values only consists of integers? True