निर्धारित करने के लिए कि क्या दो इंडेक्स ऑब्जेक्ट समान हैं, equals() मेथड का उपयोग करें।
सबसे पहले, आवश्यक लाइब्रेरी इंपोर्ट करें:
import pandas as pd
index1 और index2 बनाएं:
index1 = pd.Index([15, 25, 55, 10, 100, 70, 35, 40, 55]) index2 = pd.Index([15, 25, 55, 10, 100, 70, 35, 40, 55])
index1 और index2 प्रदर्शित करें:
print("Pandas Index1...\n", index1)
print("Pandas Index2...\n", index2)
जांचें कि क्या दो इंडेक्स ऑब्जेक्ट समान हैं:
index1.equals(index2)
उदाहरण
import pandas as pd
# Creating index1 and index2
index1 = pd.Index([15, 25, 55, 10, 100, 70, 35, 40, 55])
index2 = pd.Index([15, 25, 55, 10, 100, 70, 35, 40, 55])
# Display the index1 and index2
print("Pandas Index1...\n", index1)
print("Pandas Index2...\n", index2)
print("\nAre these two Index objects equal?\n", index1.equals(index2))
आउटपुट
Pandas Index1... Int64Index([15, 25, 55, 10, 100, 70, 35, 40, 55], dtype='int64') Pandas Index2... Int64Index([15, 25, 55, 10, 100, 70, 35, 40, 55], dtype='int64') Are these two Index objects equal? True