अनुक्रमणिका विकल्पों के संग्रह को एक साथ जोड़ने के लिए, संलग्न करें () . का उपयोग करें पंडों में विधि। सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
पांडा इंडेक्स बनाना -
index1 = pd.Index([10, 20, 30, 40, 50])
पांडा सूचकांक प्रदर्शित करें -
print("Pandas Index...\n",index1) जोड़ने के लिए एक नई अनुक्रमणिका बनाएं -
index2 = pd.Index([60, 70, 80])
नई अनुक्रमणिका जोड़ें -
print("\nAfter appending...\n",index1.append(index2)) उदाहरण
निम्नलिखित कोड है -
import pandas as pd
# Creating Pandas index
index1 = pd.Index([10, 20, 30, 40, 50])
# Display the Pandas index
print("Pandas Index...\n",index1)
# Return the number of elements in the Index
print("\nNumber of elements in the index...\n",index1.size)
# create a new index to be appended
index2 = pd.Index([60, 70, 80])
# Append the new index
print("\nAfter appending...\n",index1.append(index2)) आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
Pandas Index... Int64Index([10, 20, 30, 40, 50], dtype='int64') Number of elements in the index... 5 After appending... Int64Index([10, 20, 30, 40, 50, 60, 70, 80], dtype='int64')