यह जांचने के लिए कि क्या सूचकांक 0 तत्वों के साथ खाली है, index.खाली . का उपयोग करें पंडों में संपत्ति।
सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
अनुक्रमणिका बनाना -
index = pd.Index([])
सूचकांक प्रदर्शित करें -
print("Pandas Index...\n",index) खाली इंडेक्स की जांच करें -
print("\nIs the index empty?\n",index.empty)
उदाहरण
निम्नलिखित कोड है -
import pandas as pd
# Creating the index
index = pd.Index([])
# Display the index
print("Pandas Index...\n",index)
# Return the number of elements in the Index
print("\nNumber of elements in the index...\n",index.size)
# check for empty index
print("\nIs the index empty?\n",index.empty) आउटपुट
यह निम्नलिखित कोड उत्पन्न करेगा -
Pandas Index... Index([], dtype='object') Number of elements in the index... 0 Is the index empty? True