जांचने के लिए कि पैंडास इंडेक्स फ्लोटिंग टाइप का है या नहीं, पैंडास में index.is_floating() मेथड का उपयोग करें। सबसे पहले आवश्यक लाइब्रेरी इम्पोर्ट करें:
import pandas as pd
पैंडास इंडेक्स बनाएं:
index = pd.Index([5.7, 6.8, 10.5, 20.4, 25.6, 30.8, 40.5, 50.2])
पैंडास इंडेक्स प्रदर्शित करें:
print("Pandas Index...\n",index)
जांचें कि इंडेक्स वैल्यूज में केवल फ्लोट हैं या नहीं:
print("\nIndex values only consists of floats?\n",index.is_floating())
उदाहरण
निम्न कोड है:
import pandas as pd
# पैंडास इंडेक्स बनाना
index = pd.Index([5.7, 6.8, 10.5, 20.4, 25.6, 30.8, 40.5, 50.2])
# पैंडास इंडेक्स प्रदर्शित करना
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 floats?\n",index.is_floating())
आउटपुट
यह निम्न आउटपुट देगा:
Pandas Index... Float64Index([5.7, 6.8, 10.5, 20.4, 25.6, 30.8, 40.5, 50.2], dtype='float64') Number of elements in the index... 8 The dtype object... float64 Index values only consists of floats? True