यह दिखाने के लिए कि पंडों के सूचकांक में कौन सी प्रविष्टियाँ NA हैं, index.isna() . का उपयोग करें पंडों में। सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd import numpy as np
कुछ NaN मानों के साथ पांडा अनुक्रमणिका बनाना -
index = pd.Index([5, 65, np.nan, 17, 75, np.nan])
पांडा सूचकांक प्रदर्शित करें -
print("Pandas Index...\n",index) दिखाएँ कि पंडों के सूचकांक में कौन सी प्रविष्टियाँ NA हैं। एनए प्रविष्टियों के लिए सही लौटें -
print("\nCheck which entries are NA...\n", index.isna())
उदाहरण
निम्नलिखित कोड है -
import pandas as pd
import numpy as np
# Creating Pandas index with some NaN values
index = pd.Index([5, 65, np.nan, 17, 75, np.nan])
# Display the Pandas index
print("Pandas Index...\n",index)
# Return the number of elements in the Index
print("\nNumber of elements in the index...\n",index.size)
# Return the dtype of the data
print("\nThe dtype object...\n",index.dtype)
# Show which entries in a Pandas index are NA
# Return True for NA entries
print("\nCheck which entries are NA...\n", index.isna()) आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
Pandas Index... Float64Index([5.0, 65.0, nan, 17.0, 75.0, nan], dtype='float64') Number of elements in the index... 6 The dtype object... float64 Check which entries are NA... [False False True False False True]