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