기본 인덱스 데이터의 요소 수를 반환하려면 index.size를 사용하세요. Pandas의 속성
먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd
인덱스 생성 -
index = pd.Index([15, 25, 35, 45, 55])
인덱스 표시 -
print("Pandas Index...\n",index) 인덱스의 요소 수 반환 -
print("\nNumber of elements in the index...\n",index.size)
예시
다음은 코드입니다 -
import pandas as pd
# Creating the index
index = pd.Index([15, 25, 35, 45, 55])
# 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)
# Return a tuple of the shape of the underlying data
print("\nA tuple of the shape of underlying data...\n",index.shape)
# get the bytes in the data
print("\nReturn the bytes...\n",index.nbytes)
# get the dimensions of the data
print("\nReturn the dimensions...\n",index.ndim) 출력
이것은 다음 코드를 생성합니다 -
Pandas Index... Int64Index([15, 25, 35, 45, 55], dtype='int64') Number of elements in the index... 5 A tuple of the shape of underlying data... (5,) Return the bytes... 40 Return the dimensions... 1