색인 옵션 모음을 함께 추가하려면 append()를 사용하세요. Pandas의 메소드. 먼저 필요한 라이브러리를 가져옵니다 -
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')